Beispiel #1
0
 public static byte[] CmdToBytes <T>(NetCmdBase cmd, int prefixLength)
 {
     byte[] data = TypeReflector.ObjToBytes <T>(cmd, prefixLength);
     if (data == null)
     {
         LogMgr.Log("Unregister cmd type:" + cmd.GetCmdType());
     }
     else
     {
         data[0] = (byte)data.Length;
         data[1] = (byte)(data.Length >> 8);
     }
     return(data);
 }
Beispiel #2
0
 public static byte[] CmdToBytes(SendCmdPack pack, int prefixSize)
 {
     byte[] data = TypeReflector.ObjToBytes(pack.Cmd, pack.Hash, prefixSize);
     if (data == null)
     {
         LogMgr.Log("Unregister cmd type:" + pack.Cmd.GetCmdType());
     }
     else
     {
         int length = data.Length - prefixSize;
         data[prefixSize]     = (byte)length;
         data[prefixSize + 1] = (byte)(length >> 8);
     }
     return(data);
 }