Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
guo450212436
et
提交
e76a4fe0
E
et
项目概览
guo450212436
/
et
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
et
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e76a4fe0
编写于
7月 29, 2020
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复服务端启动错误
上级
aa148b84
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
25 addition
and
129 deletion
+25
-129
Excel/StartMachineConfig.xlsx
Excel/StartMachineConfig.xlsx
+0
-0
Server/Hotfix/Module/Message/NetInnerComponentSystem.cs
Server/Hotfix/Module/Message/NetInnerComponentSystem.cs
+2
-2
Server/Model/Demo/ConfigPartial/StartProcessConfig.cs
Server/Model/Demo/ConfigPartial/StartProcessConfig.cs
+1
-1
Server/Model/Server.Model.csproj
Server/Model/Server.Model.csproj
+0
-1
Unity/Assets/HotfixView/AppStart_Init.cs
Unity/Assets/HotfixView/AppStart_Init.cs
+1
-1
Unity/Assets/Model/Base/Event/IEvent.cs
Unity/Assets/Model/Base/Event/IEvent.cs
+1
-1
Unity/Assets/Model/Base/TryLocker.cs
Unity/Assets/Model/Base/TryLocker.cs
+0
-35
Unity/Assets/Model/Base/TryLocker.cs.meta
Unity/Assets/Model/Base/TryLocker.cs.meta
+0
-12
Unity/Assets/Model/Define.cs
Unity/Assets/Model/Define.cs
+0
-18
Unity/Assets/Model/Module/Message/Network/TCP/PacketParser.cs
...y/Assets/Model/Module/Message/Network/TCP/PacketParser.cs
+7
-24
Unity/Assets/Model/Module/Message/Network/TCP/TChannel.cs
Unity/Assets/Model/Module/Message/Network/TCP/TChannel.cs
+7
-23
Unity/Assets/Model/Module/Message/Network/TCP/TService.cs
Unity/Assets/Model/Module/Message/Network/TCP/TService.cs
+2
-6
Unity/Assets/Model/Module/Message/NetworkComponent.cs
Unity/Assets/Model/Module/Message/NetworkComponent.cs
+4
-4
Unity/Unity.Model.csproj
Unity/Unity.Model.csproj
+0
-1
未找到文件。
Excel/StartMachineConfig.xlsx
浏览文件 @
e76a4fe0
无法预览此类型文件
Server/Hotfix/Module/Message/NetInnerComponentSystem.cs
浏览文件 @
e76a4fe0
...
...
@@ -7,7 +7,7 @@ namespace ET
public
override
void
Awake
(
NetInnerComponent
self
)
{
NetInnerComponent
.
Instance
=
self
;
self
.
Awake
(
NetworkProtocol
.
TCP
,
Packet
.
PacketSizeLength4
);
self
.
Awake
(
NetworkProtocol
.
TCP
);
self
.
MessagePacker
=
new
MongoPacker
();
self
.
MessageDispatcher
=
new
InnerMessageDispatcher
();
}
...
...
@@ -18,7 +18,7 @@ namespace ET
public
override
void
Awake
(
NetInnerComponent
self
,
string
a
)
{
NetInnerComponent
.
Instance
=
self
;
self
.
Awake
(
NetworkProtocol
.
TCP
,
a
,
Packet
.
PacketSizeLength4
);
self
.
Awake
(
NetworkProtocol
.
TCP
,
a
);
self
.
MessagePacker
=
new
MongoPacker
();
self
.
MessageDispatcher
=
new
InnerMessageDispatcher
();
}
...
...
Server/Model/Demo/ConfigPartial/StartProcessConfig.cs
浏览文件 @
e76a4fe0
...
...
@@ -19,7 +19,7 @@ namespace ET
{
if
(
this
.
innerAddress
==
null
)
{
this
.
innerAddress
=
$"
{
StartMachineConfigCategory
.
Instance
.
Get
(
this
.
MachineId
)}
:
{
this
.
InnerPort
}
"
;
this
.
innerAddress
=
$"
{
StartMachineConfigCategory
.
Instance
.
Get
(
this
.
MachineId
)
.
InnerIP
}
:
{
this
.
InnerPort
}
"
;
}
return
this
.
innerAddress
;
}
...
...
Server/Model/Server.Model.csproj
浏览文件 @
e76a4fe0
...
...
@@ -214,7 +214,6 @@
<Compile Include="..\..\Unity\Assets\Model\Base\RecyclableMemoryStream\Events.cs" Link="Base\RecyclableMemoryStream\Events.cs" />
<Compile Include="..\..\Unity\Assets\Model\Base\RecyclableMemoryStream\RecyclableMemoryStream.cs" Link="Base\RecyclableMemoryStream\RecyclableMemoryStream.cs" />
<Compile Include="..\..\Unity\Assets\Model\Base\RecyclableMemoryStream\RecyclableMemoryStreamManager.cs" Link="Base\RecyclableMemoryStream\RecyclableMemoryStreamManager.cs" />
<Compile Include="..\..\Unity\Assets\Model\Base\TryLocker.cs" Link="Base\TryLocker.cs" />
<Compile Include="..\..\Unity\Assets\Model\Base\UnOrderMultiMap.cs" Link="Base\UnOrderMultiMap.cs" />
<Compile Include="..\..\Unity\Assets\Model\Module\Config\ACategory.cs" Link="Module\Config\ACategory.cs" />
<Compile Include="..\..\Unity\Assets\Model\Module\Config\ConfigAttribute.cs" Link="Module\Config\ConfigAttribute.cs" />
...
...
Unity/Assets/HotfixView/AppStart_Init.cs
浏览文件 @
e76a4fe0
...
...
@@ -11,7 +11,7 @@ namespace ET
//await BundleHelper.DownloadBundle("1111");
// 加载配置
Game
.
Scene
.
Get
Component
<
ResourcesComponent
>().
LoadBundle
(
"config.unity3d"
);
Game
.
Scene
.
Add
Component
<
ResourcesComponent
>().
LoadBundle
(
"config.unity3d"
);
Game
.
Scene
.
AddComponent
<
ConfigComponent
>();
Game
.
Scene
.
GetComponent
<
ResourcesComponent
>().
UnloadBundle
(
"config.unity3d"
);
Game
.
Scene
.
AddComponent
<
OpcodeTypeComponent
>();
...
...
Unity/Assets/Model/Base/Event/IEvent.cs
浏览文件 @
e76a4fe0
...
...
@@ -7,7 +7,7 @@ namespace ET
Type
GetEventType
();
}
[
Event
]
public
abstract
class
AEvent
<
A
>:
IEvent
where
A
:
struct
{
public
Type
GetEventType
()
...
...
Unity/Assets/Model/Base/TryLocker.cs
已删除
100644 → 0
浏览文件 @
aa148b84
using
System
;
using
System.Threading
;
namespace
ET
{
public
class
TryLock
:
IDisposable
{
private
object
locked
;
public
bool
HasLock
{
get
;
private
set
;
}
public
TryLock
(
object
obj
)
{
if
(!
Monitor
.
TryEnter
(
obj
))
{
return
;
}
this
.
HasLock
=
true
;
this
.
locked
=
obj
;
}
public
void
Dispose
()
{
if
(!
this
.
HasLock
)
{
return
;
}
Monitor
.
Exit
(
this
.
locked
);
this
.
locked
=
null
;
this
.
HasLock
=
false
;
}
}
}
Unity/Assets/Model/Base/TryLocker.cs.meta
已删除
100644 → 0
浏览文件 @
aa148b84
fileFormatVersion: 2
guid: b17c37646ccfe6d4d96df611e5664f8c
timeCreated: 1476430040
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Unity/Assets/Model/Define.cs
浏览文件 @
e76a4fe0
...
...
@@ -7,23 +7,5 @@
#else
public
static
bool
IsAsync
=
true
;
#endif
#if UNITY_EDITOR
public
static
bool
IsEditorMode
=
true
;
#else
public
static
bool
IsEditorMode
=
false
;
#endif
#if DEVELOPMENT_BUILD
public
static
bool
IsDevelopmentBuild
=
true
;
#else
public
static
bool
IsDevelopmentBuild
=
false
;
#endif
#if ILRuntime
public
static
bool
IsILRuntime
=
true
;
#else
public
static
bool
IsILRuntime
=
false
;
#endif
}
}
\ No newline at end of file
Unity/Assets/Model/Module/Message/Network/TCP/PacketParser.cs
浏览文件 @
e76a4fe0
...
...
@@ -11,8 +11,7 @@ namespace ET
public
static
class
Packet
{
public
const
int
PacketSizeLength2
=
2
;
public
const
int
PacketSizeLength4
=
4
;
public
const
int
PacketSizeLength
=
4
;
public
const
int
MinPacketSize
=
2
;
public
const
int
OpcodeIndex
=
0
;
public
const
int
MessageIndex
=
2
;
...
...
@@ -25,11 +24,9 @@ namespace ET
private
ParserState
state
;
public
MemoryStream
memoryStream
;
private
bool
isOK
;
private
readonly
int
packetSizeLength
;
public
PacketParser
(
int
packetSizeLength
,
CircularBuffer
buffer
,
MemoryStream
memoryStream
)
public
PacketParser
(
CircularBuffer
buffer
,
MemoryStream
memoryStream
)
{
this
.
packetSizeLength
=
packetSizeLength
;
this
.
buffer
=
buffer
;
this
.
memoryStream
=
memoryStream
;
}
...
...
@@ -47,32 +44,18 @@ namespace ET
switch
(
this
.
state
)
{
case
ParserState
.
PacketSize
:
if
(
this
.
buffer
.
Length
<
this
.
p
acketSizeLength
)
if
(
this
.
buffer
.
Length
<
Packet
.
P
acketSizeLength
)
{
finish
=
true
;
}
else
{
this
.
buffer
.
Read
(
this
.
memoryStream
.
GetBuffer
(),
0
,
this
.
p
acketSizeLength
);
this
.
buffer
.
Read
(
this
.
memoryStream
.
GetBuffer
(),
0
,
Packet
.
P
acketSizeLength
);
switch
(
this
.
packetSizeLength
)
this
.
packetSize
=
BitConverter
.
ToInt32
(
this
.
memoryStream
.
GetBuffer
(),
0
);
if
(
this
.
packetSize
>
ushort
.
MaxValue
*
16
||
this
.
packetSize
<
Packet
.
MinPacketSize
)
{
case
Packet
.
PacketSizeLength4
:
this
.
packetSize
=
BitConverter
.
ToInt32
(
this
.
memoryStream
.
GetBuffer
(),
0
);
if
(
this
.
packetSize
>
ushort
.
MaxValue
*
16
||
this
.
packetSize
<
Packet
.
MinPacketSize
)
{
throw
new
Exception
(
$"recv packet size error, 可能是外网探测端口:
{
this
.
packetSize
}
"
);
}
break
;
case
Packet
.
PacketSizeLength2
:
this
.
packetSize
=
BitConverter
.
ToUInt16
(
this
.
memoryStream
.
GetBuffer
(),
0
);
if
(
this
.
packetSize
>
ushort
.
MaxValue
||
this
.
packetSize
<
Packet
.
MinPacketSize
)
{
throw
new
Exception
(
$"recv packet size error:, 可能是外网探测端口:
{
this
.
packetSize
}
"
);
}
break
;
default
:
throw
new
Exception
(
"packet size byte count must be 2 or 4!"
);
throw
new
Exception
(
$"recv packet size error, 可能是外网探测端口:
{
this
.
packetSize
}
"
);
}
this
.
state
=
ParserState
.
PacketBody
;
}
...
...
Unity/Assets/Model/Module/Message/Network/TCP/TChannel.cs
浏览文件 @
e76a4fe0
...
...
@@ -34,13 +34,12 @@ namespace ET
public
TChannel
(
IPEndPoint
ipEndPoint
,
TService
service
):
base
(
service
,
ChannelType
.
Connect
)
{
int
packetSize
=
service
.
PacketSizeLength
;
this
.
packetSizeCache
=
new
byte
[
packetSize
];
this
.
packetSizeCache
=
new
byte
[
4
];
this
.
memoryStream
=
service
.
MemoryStreamManager
.
GetStream
(
"message"
,
ushort
.
MaxValue
);
this
.
socket
=
new
Socket
(
AddressFamily
.
InterNetwork
,
SocketType
.
Stream
,
ProtocolType
.
Tcp
);
this
.
socket
.
NoDelay
=
true
;
this
.
parser
=
new
PacketParser
(
packetSize
,
this
.
recvBuffer
,
this
.
memoryStream
);
this
.
parser
=
new
PacketParser
(
this
.
recvBuffer
,
this
.
memoryStream
);
this
.
innArgs
.
Completed
+=
this
.
OnComplete
;
this
.
outArgs
.
Completed
+=
this
.
OnComplete
;
...
...
@@ -52,13 +51,12 @@ namespace ET
public
TChannel
(
Socket
socket
,
TService
service
):
base
(
service
,
ChannelType
.
Accept
)
{
int
packetSize
=
service
.
PacketSizeLength
;
this
.
packetSizeCache
=
new
byte
[
packetSize
];
this
.
packetSizeCache
=
new
byte
[
Packet
.
PacketSizeLength
];
this
.
memoryStream
=
service
.
MemoryStreamManager
.
GetStream
(
"message"
,
ushort
.
MaxValue
);
this
.
socket
=
socket
;
this
.
socket
.
NoDelay
=
true
;
this
.
parser
=
new
PacketParser
(
packetSize
,
this
.
recvBuffer
,
this
.
memoryStream
);
this
.
parser
=
new
PacketParser
(
this
.
recvBuffer
,
this
.
memoryStream
);
this
.
innArgs
.
Completed
+=
this
.
OnComplete
;
this
.
outArgs
.
Completed
+=
this
.
OnComplete
;
...
...
@@ -118,25 +116,11 @@ namespace ET
throw
new
Exception
(
"TChannel已经被Dispose, 不能发送消息"
);
}
switch
(
this
.
GetService
().
PacketSizeLength
)
if
(
stream
.
Length
>
ushort
.
MaxValue
*
16
)
{
case
Packet
.
PacketSizeLength4
:
if
(
stream
.
Length
>
ushort
.
MaxValue
*
16
)
{
throw
new
Exception
(
$"send packet too large:
{
stream
.
Length
}
"
);
}
this
.
packetSizeCache
.
WriteTo
(
0
,
(
int
)
stream
.
Length
);
break
;
case
Packet
.
PacketSizeLength2
:
if
(
stream
.
Length
>
ushort
.
MaxValue
)
{
throw
new
Exception
(
$"send packet too large:
{
stream
.
Length
}
"
);
}
this
.
packetSizeCache
.
WriteTo
(
0
,
(
ushort
)
stream
.
Length
);
break
;
default
:
throw
new
Exception
(
"packet size must be 2 or 4!"
);
throw
new
Exception
(
$"send packet too large:
{
stream
.
Length
}
"
);
}
this
.
packetSizeCache
.
WriteTo
(
0
,
(
int
)
stream
.
Length
);
this
.
sendBuffer
.
Write
(
this
.
packetSizeCache
,
0
,
this
.
packetSizeCache
.
Length
);
this
.
sendBuffer
.
Write
(
stream
);
...
...
Unity/Assets/Model/Module/Message/Network/TCP/TService.cs
浏览文件 @
e76a4fe0
...
...
@@ -18,14 +18,11 @@ namespace ET
public
List
<
long
>
needStartSendChannel
=
new
List
<
long
>();
public
int
PacketSizeLength
{
get
;
}
/// <summary>
/// 即可做client也可做server
/// </summary>
public
TService
(
int
packetSizeLength
,
IPEndPoint
ipEndPoint
,
Action
<
AChannel
>
acceptCallback
)
public
TService
(
IPEndPoint
ipEndPoint
,
Action
<
AChannel
>
acceptCallback
)
{
this
.
PacketSizeLength
=
packetSizeLength
;
this
.
AcceptCallback
+=
acceptCallback
;
this
.
acceptor
=
new
Socket
(
AddressFamily
.
InterNetwork
,
SocketType
.
Stream
,
ProtocolType
.
Tcp
);
...
...
@@ -38,9 +35,8 @@ namespace ET
this
.
AcceptAsync
();
}
public
TService
(
int
packetSizeLength
)
public
TService
()
{
this
.
PacketSizeLength
=
packetSizeLength
;
}
public
override
void
Dispose
()
...
...
Unity/Assets/Model/Module/Message/NetworkComponent.cs
浏览文件 @
e76a4fe0
...
...
@@ -14,7 +14,7 @@ namespace ET
public
IMessageDispatcher
MessageDispatcher
{
get
;
set
;
}
public
void
Awake
(
NetworkProtocol
protocol
,
int
packetSize
=
Packet
.
PacketSizeLength4
)
public
void
Awake
(
NetworkProtocol
protocol
)
{
switch
(
protocol
)
{
...
...
@@ -22,7 +22,7 @@ namespace ET
this
.
Service
=
new
KService
()
{
Parent
=
this
};
break
;
case
NetworkProtocol
.
TCP
:
this
.
Service
=
new
TService
(
packetSize
)
{
Parent
=
this
};
this
.
Service
=
new
TService
()
{
Parent
=
this
};
break
;
case
NetworkProtocol
.
WebSocket
:
this
.
Service
=
new
WService
()
{
Parent
=
this
};
...
...
@@ -30,7 +30,7 @@ namespace ET
}
}
public
void
Awake
(
NetworkProtocol
protocol
,
string
address
,
int
packetSize
=
Packet
.
PacketSizeLength4
)
public
void
Awake
(
NetworkProtocol
protocol
,
string
address
)
{
try
{
...
...
@@ -43,7 +43,7 @@ namespace ET
break
;
case
NetworkProtocol
.
TCP
:
ipEndPoint
=
NetworkHelper
.
ToIPEndPoint
(
address
);
this
.
Service
=
new
TService
(
packetSize
,
ipEndPoint
,
(
channel
)=>
{
this
.
OnAccept
(
channel
);
})
{
Parent
=
this
};
this
.
Service
=
new
TService
(
ipEndPoint
,
(
channel
)=>
{
this
.
OnAccept
(
channel
);
})
{
Parent
=
this
};
break
;
case
NetworkProtocol
.
WebSocket
:
string
[]
prefixs
=
address
.
Split
(
';'
);
...
...
Unity/Unity.Model.csproj
浏览文件 @
e76a4fe0
...
...
@@ -127,7 +127,6 @@
<Compile
Include=
"Assets\Model\Base\RecyclableMemoryStream\RecyclableMemoryStream.cs"
/>
<Compile
Include=
"Assets\Model\Base\RecyclableMemoryStream\RecyclableMemoryStreamManager.cs"
/>
<Compile
Include=
"Assets\Model\Base\StructBsonSerialize.cs"
/>
<Compile
Include=
"Assets\Model\Base\TryLocker.cs"
/>
<Compile
Include=
"Assets\Model\Base\UnOrderMultiMap.cs"
/>
<Compile
Include=
"Assets\Model\Base\UnOrderMultiMapSet.cs"
/>
<Compile
Include=
"Assets\Model\Config\StartMachineConfig.cs"
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录