From caca938059f456ace5082493b66b46e2e01f73e9 Mon Sep 17 00:00:00 2001 From: azw Date: Wed, 22 May 2024 09:05:09 +0800 Subject: [PATCH] 1 --- F6/MsgHandler.cs | 10 +++++----- Net/ClientNet.cs | 11 +++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/F6/MsgHandler.cs b/F6/MsgHandler.cs index ea12722..f92568f 100644 --- a/F6/MsgHandler.cs +++ b/F6/MsgHandler.cs @@ -31,14 +31,14 @@ namespace F6 this.smMsgType = smMsgType; } - public int GetCMMsgId(string msgName) + public int GetCMMsgId(Type type) { - return this.GetPbMsgId(this.cmMsgType, "_" + msgName); + return this.GetPbMsgId(this.cmMsgType, "_" + type.Name); } - public int GetSMMsgId(string msgName) + public int GetSMMsgId(Type type) { - return this.GetPbMsgId(this.smMsgType, "_" + msgName); + return this.GetPbMsgId(this.smMsgType, "_" + type.Name); } public int GetPbMsgId(Type enumType, string msgName) @@ -61,7 +61,7 @@ namespace F6 protected void RegisterHandler(HandlerDelegate handler) where T : IMessage ,new() { - int msgId = this.GetSMMsgId(typeof(T).Name); + int msgId = this.GetSMMsgId(typeof(T)); HandlerRec handler1; if (!this.handlerHash.TryGetValue(msgId, out handler1)) { diff --git a/Net/ClientNet.cs b/Net/ClientNet.cs index 7cbd9af..6e4bab3 100644 --- a/Net/ClientNet.cs +++ b/Net/ClientNet.cs @@ -6,7 +6,6 @@ using System; using System.Collections.Generic; using Google.Protobuf; -using pbr = global::Google.Protobuf.Reflection; namespace Net { @@ -52,7 +51,7 @@ namespace Net { try { - int msgId = this.msgHandler.GetCMMsgId(typeof(T).Name); + int msgId = this.msgHandler.GetCMMsgId(typeof(T)); int packLen = msg.CalculateSize(); const int magicCode = 21323; byte[] data = new byte[12 + packLen]; @@ -84,7 +83,6 @@ namespace Net private void OnWsBinaryReceived(WebSocket ws, byte[] data) { - Debug.Log("ClientNet.OnBinaryReceived"); this.AddEvent(EventType.Read, new object[]{data.Clone()}); } @@ -119,6 +117,11 @@ namespace Net } } + private void ParsePkt(byte[] data) + { + + } + private void DispatchEvent(KeyValuePair e) { switch (e.Key) @@ -149,7 +152,7 @@ namespace Net break; case EventType.Read: { - + this.ParsePkt((byte[])e.Value[0]); } break; }