This commit is contained in:
azw 2024-05-22 09:05:09 +08:00
parent d936cd3ef4
commit caca938059
2 changed files with 12 additions and 9 deletions

View File

@ -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<T>(HandlerDelegate<T> handler) where T : IMessage<T> ,new()
{
int msgId = this.GetSMMsgId(typeof(T).Name);
int msgId = this.GetSMMsgId(typeof(T));
HandlerRec handler1;
if (!this.handlerHash.TryGetValue(msgId, out handler1))
{

View File

@ -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<EventType, object[]> e)
{
switch (e.Key)
@ -149,7 +152,7 @@ namespace Net
break;
case EventType.Read:
{
this.ParsePkt((byte[])e.Value[0]);
}
break;
}