diff --git a/Excel/StartMachineConfig.xlsx b/Excel/StartMachineConfig.xlsx
index 5616411737bc27907e461a5986b9fbe5a2a35a81..ce79cee7979b08377f4614ead7c83a42064f92c8 100644
Binary files a/Excel/StartMachineConfig.xlsx and b/Excel/StartMachineConfig.xlsx differ
diff --git a/Server/Hotfix/Module/Message/NetInnerComponentSystem.cs b/Server/Hotfix/Module/Message/NetInnerComponentSystem.cs
index 6b5e2e425f110c4b1a8fbe0f7aa114e562e16ace..c03ed37ec9303c27738732a8257cefaab5c00492 100644
--- a/Server/Hotfix/Module/Message/NetInnerComponentSystem.cs
+++ b/Server/Hotfix/Module/Message/NetInnerComponentSystem.cs
@@ -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();
}
diff --git a/Server/Model/Demo/ConfigPartial/StartProcessConfig.cs b/Server/Model/Demo/ConfigPartial/StartProcessConfig.cs
index 21c437da0f034765c68fd0a5c6bf00956284b181..0c82c60c1a6f163a76e78852cfb3f7f466cf9f27 100644
--- a/Server/Model/Demo/ConfigPartial/StartProcessConfig.cs
+++ b/Server/Model/Demo/ConfigPartial/StartProcessConfig.cs
@@ -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;
}
diff --git a/Server/Model/Server.Model.csproj b/Server/Model/Server.Model.csproj
index 6ba8c40308ea11148978ebb7e92e699cecc97d06..d663396cd7bbad9b14fbf0783ad43e6353623694 100644
--- a/Server/Model/Server.Model.csproj
+++ b/Server/Model/Server.Model.csproj
@@ -214,7 +214,6 @@
-
diff --git a/Unity/Assets/HotfixView/AppStart_Init.cs b/Unity/Assets/HotfixView/AppStart_Init.cs
index 59c58532db6505977f132861d42372a86a817f38..2cf6266af0aed824577fe1b71c782f7e8d7ccbfb 100644
--- a/Unity/Assets/HotfixView/AppStart_Init.cs
+++ b/Unity/Assets/HotfixView/AppStart_Init.cs
@@ -11,7 +11,7 @@ namespace ET
//await BundleHelper.DownloadBundle("1111");
// 加载配置
- Game.Scene.GetComponent().LoadBundle("config.unity3d");
+ Game.Scene.AddComponent().LoadBundle("config.unity3d");
Game.Scene.AddComponent();
Game.Scene.GetComponent().UnloadBundle("config.unity3d");
Game.Scene.AddComponent();
diff --git a/Unity/Assets/Model/Base/Event/IEvent.cs b/Unity/Assets/Model/Base/Event/IEvent.cs
index 1333fb7890a1f308d15e4ca6ceac4e67a32bf812..68537abd456b0d020a3cc36f596596d2c5db8804 100644
--- a/Unity/Assets/Model/Base/Event/IEvent.cs
+++ b/Unity/Assets/Model/Base/Event/IEvent.cs
@@ -7,7 +7,7 @@ namespace ET
Type GetEventType();
}
-
+ [Event]
public abstract class AEvent: IEvent where A: struct
{
public Type GetEventType()
diff --git a/Unity/Assets/Model/Base/TryLocker.cs b/Unity/Assets/Model/Base/TryLocker.cs
deleted file mode 100644
index 29c14273a564099f280ad3f91168ff80c6fcd345..0000000000000000000000000000000000000000
--- a/Unity/Assets/Model/Base/TryLocker.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-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;
- }
- }
-}
diff --git a/Unity/Assets/Model/Base/TryLocker.cs.meta b/Unity/Assets/Model/Base/TryLocker.cs.meta
deleted file mode 100644
index 972a879c1281ef4000c50108b9baa1da6507bdf5..0000000000000000000000000000000000000000
--- a/Unity/Assets/Model/Base/TryLocker.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: b17c37646ccfe6d4d96df611e5664f8c
-timeCreated: 1476430040
-licenseType: Pro
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Unity/Assets/Model/Define.cs b/Unity/Assets/Model/Define.cs
index 973eef8f1da7760f4ca490ea135d6f2ca1ced25e..965d5f6a8f6c6003342916d797079ad8a18fdde1 100644
--- a/Unity/Assets/Model/Define.cs
+++ b/Unity/Assets/Model/Define.cs
@@ -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
diff --git a/Unity/Assets/Model/Module/Message/Network/TCP/PacketParser.cs b/Unity/Assets/Model/Module/Message/Network/TCP/PacketParser.cs
index cada1df46ca386cfe2e93e21988e166079dfa37f..98f2e30e14c07077365689ea82198f39ee18bbee 100644
--- a/Unity/Assets/Model/Module/Message/Network/TCP/PacketParser.cs
+++ b/Unity/Assets/Model/Module/Message/Network/TCP/PacketParser.cs
@@ -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.packetSizeLength)
+ if (this.buffer.Length < Packet.PacketSizeLength)
{
finish = true;
}
else
{
- this.buffer.Read(this.memoryStream.GetBuffer(), 0, this.packetSizeLength);
+ this.buffer.Read(this.memoryStream.GetBuffer(), 0, Packet.PacketSizeLength);
- 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;
}
diff --git a/Unity/Assets/Model/Module/Message/Network/TCP/TChannel.cs b/Unity/Assets/Model/Module/Message/Network/TCP/TChannel.cs
index 62471ef57a7376f46814115264837f32d63c1300..9dccbe278849bdca5b9864383449cbc6209be383 100644
--- a/Unity/Assets/Model/Module/Message/Network/TCP/TChannel.cs
+++ b/Unity/Assets/Model/Module/Message/Network/TCP/TChannel.cs
@@ -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);
diff --git a/Unity/Assets/Model/Module/Message/Network/TCP/TService.cs b/Unity/Assets/Model/Module/Message/Network/TCP/TService.cs
index 91deb05c4d8ed182459b64470061076cc5615ee6..8e2b5ebdbc5f5edfbf29f042c57a0807fd8d4d88 100644
--- a/Unity/Assets/Model/Module/Message/Network/TCP/TService.cs
+++ b/Unity/Assets/Model/Module/Message/Network/TCP/TService.cs
@@ -18,14 +18,11 @@ namespace ET
public List needStartSendChannel = new List();
- public int PacketSizeLength { get; }
-
///
/// 即可做client也可做server
///
- public TService(int packetSizeLength, IPEndPoint ipEndPoint, Action acceptCallback)
+ public TService(IPEndPoint ipEndPoint, Action 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()
diff --git a/Unity/Assets/Model/Module/Message/NetworkComponent.cs b/Unity/Assets/Model/Module/Message/NetworkComponent.cs
index 80a545b5169d880ee3df9b950d305dfc70e74a01..3cfdaa9def51202988a45969a761a28364fde931 100644
--- a/Unity/Assets/Model/Module/Message/NetworkComponent.cs
+++ b/Unity/Assets/Model/Module/Message/NetworkComponent.cs
@@ -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(';');
diff --git a/Unity/Unity.Model.csproj b/Unity/Unity.Model.csproj
index 39e61be9a547664cfa0e78aa391922a2117d553d..aeacaa162c378089a20cabc0498793b7cdd21c31 100644
--- a/Unity/Unity.Model.csproj
+++ b/Unity/Unity.Model.csproj
@@ -127,7 +127,6 @@
-