Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
若汝棋茗
RRQMSocket
提交
0dfbc002
RRQMSocket
项目概览
若汝棋茗
/
RRQMSocket
11 个月 前同步成功
通知
20
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
RRQMSocket
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0dfbc002
编写于
9月 18, 2022
作者:
若
若汝棋茗
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
U3D示例增加Udp、UdpRpc示例
上级
76c63548
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
51 addition
and
33 deletion
+51
-33
examples/Unity3d简单示例/UnityPackage/TestTouchSocket.unitypackage
...les/Unity3d简单示例/UnityPackage/TestTouchSocket.unitypackage
+0
-0
examples/Unity3d简单示例/UnityServer/UnityServer.sln
examples/Unity3d简单示例/UnityServer/UnityServer.sln
+0
-25
examples/Unity3d简单示例/UnityServer/UnityServerConsoleApp/Program.cs
.../Unity3d简单示例/UnityServer/UnityServerConsoleApp/Program.cs
+51
-8
examples/Unity3d简单示例/publish_win86_win64_android.7z
examples/Unity3d简单示例/publish_win86_win64_android.7z
+0
-0
未找到文件。
examples/Unity3d简单示例/UnityPackage/TestTouchSocket.unitypackage
浏览文件 @
0dfbc002
无法预览此类型文件
examples/Unity3d简单示例/UnityServer/UnityServer.sln
已删除
100644 → 0
浏览文件 @
76c63548
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32811.315
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityServerConsoleApp", "UnityServerConsoleApp\UnityServerConsoleApp.csproj", "{92C0DFB7-E3EC-499D-85C7-69A3ED344264}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{92C0DFB7-E3EC-499D-85C7-69A3ED344264}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{92C0DFB7-E3EC-499D-85C7-69A3ED344264}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92C0DFB7-E3EC-499D-85C7-69A3ED344264}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92C0DFB7-E3EC-499D-85C7-69A3ED344264}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {324D4D22-4EC7-457E-BD31-E23431C21FC4}
EndGlobalSection
EndGlobal
examples/Unity3d简单示例/UnityServer/UnityServerConsoleApp/Program.cs
浏览文件 @
0dfbc002
...
...
@@ -23,16 +23,59 @@ namespace UnityServerConsoleApp
{
//unitypackage在本级目录下。
//已发布的apk和exe客户端也在本级目录下。
StartTcpService
();
StartTcpRpcService
();
StartTcpService
(
7789
);
StartTcpRpcService
(
7790
);
StartUdpService
(
7791
);
StartUdpRpc
(
7792
);
Console
.
ReadKey
();
}
static
void
StartTcpRpcService
()
static
void
StartUdpRpc
(
int
port
)
{
var
service
=
new
UdpTouchRpc
();
TouchSocketConfig
config
=
new
TouchSocketConfig
()
//配置
.
SetBindIPHost
(
new
IPHost
(
port
))
.
ConfigureContainer
(
a
=>
{
a
.
SetSingletonLogger
<
ConsoleLogger
>();
//注册一个日志组
})
.
ConfigureRpcStore
(
a
=>
{
a
.
RegisterServer
<
MyRpcServer
>();
//注册服务
});
service
.
Setup
(
config
)
.
Start
();
service
.
Logger
.
Info
(
$"
{
service
.
GetType
().
Name
}
已启动,监听端口:
{
port
}
"
);
}
static
void
StartUdpService
(
int
port
)
{
UdpSession
udpService
=
new
UdpSession
();
udpService
.
Received
+=
(
remote
,
byteBlock
,
requestInfo
)
=>
{
udpService
.
Send
(
remote
,
byteBlock
);
Console
.
WriteLine
(
$"收到:
{
Encoding
.
UTF8
.
GetString
(
byteBlock
.
Buffer
,
0
,
byteBlock
.
Len
)}
"
);
};
udpService
.
Setup
(
new
TouchSocketConfig
()
.
SetBindIPHost
(
new
IPHost
(
port
))
.
SetUdpDataHandlingAdapter
(()
=>
new
NormalUdpDataHandlingAdapter
())
//常规udp
//.SetUdpDataHandlingAdapter(() => new UdpPackageAdapter())//Udp包模式,支持超过64k数据。
.
ConfigureContainer
(
a
=>
{
a
.
SetSingletonLogger
<
ConsoleLogger
>();
//添加一个日志注入
}))
.
Start
();
udpService
.
Logger
.
Info
(
$"UdpService已启动,端口:
{
port
}
"
);
}
static
void
StartTcpRpcService
(
int
port
)
{
var
service
=
new
TcpTouchRpcService
();
TouchSocketConfig
config
=
new
TouchSocketConfig
()
//配置
.
SetListenIPHosts
(
new
IPHost
[]
{
new
IPHost
(
7790
)
})
.
SetListenIPHosts
(
new
IPHost
[]
{
new
IPHost
(
port
)
})
.
SetThreadCount
(
50
)
.
UseDelaySender
()
.
UsePlugin
()
...
...
@@ -53,7 +96,7 @@ namespace UnityServerConsoleApp
service
.
Setup
(
config
)
.
Start
();
service
.
Logger
.
Info
(
$"
{
service
.
GetType
().
Name
}
已启动,监听端口:
{
7790
}
"
);
service
.
Logger
.
Info
(
$"
{
service
.
GetType
().
Name
}
已启动,监听端口:
{
port
}
"
);
string
code
=
service
.
RpcStore
.
GetProxyCodes
(
"TcpRpcProxy"
);
File
.
WriteAllText
(
"TcpRpcProxy.cs"
,
code
);
...
...
@@ -61,11 +104,11 @@ namespace UnityServerConsoleApp
//service.RpcStore.ShareProxy(new IPHost(8848));
}
static
void
StartTcpService
()
static
void
StartTcpService
(
int
port
)
{
TcpService
service
=
new
TcpService
();
service
.
Setup
(
new
TouchSocketConfig
()
//载入配置
.
SetListenIPHosts
(
new
IPHost
[]
{
new
IPHost
(
7789
)
})
//同时监听两个地址
.
SetListenIPHosts
(
new
IPHost
[]
{
new
IPHost
(
port
)
})
//同时监听两个地址
.
SetMaxCount
(
10000
)
.
SetThreadCount
(
10
)
.
UsePlugin
()
...
...
@@ -79,7 +122,7 @@ namespace UnityServerConsoleApp
a
.
SetSingletonLogger
<
ConsoleLogger
>();
//添加一个日志注入
}))
.
Start
();
//启动
service
.
Logger
.
Info
(
"Tcp服务器已启动,端口7789
"
);
service
.
Logger
.
Info
(
$"Tcp服务器已启动,端口
{
port
}
"
);
}
}
...
...
examples/Unity3d简单示例/publish_win86_win64_android.7z
浏览文件 @
0dfbc002
无法预览此类型文件
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录