Ejemplo n.º 1
0
 public override void Deserialize(JHSNetworkReader reader)
 {
     op = (SearchMatchOperations)reader.ReadByte();
     if (op == SearchMatchOperations.Search)
     {
         value = reader.ReadPackedUInt32();
     }
     if (op == SearchMatchOperations.START)
     {
         IP   = reader.ReadString();
         port = reader.ReadInt16();
     }
 }
Ejemplo n.º 2
0
 protected bool HandleReader(JHSNetworkReader reader)
 {
     try
     {
         ushort sz        = reader.ReadUInt16();
         short  msgType   = reader.ReadInt16();
         byte[] msgBuffer = reader.ReadBytes(sz);
         if (isClient)
         {
             JHSNetworkReader msgReader = new JHSNetworkReader(msgBuffer);
             if (m_MessageHandlersDict.ContainsKey(msgType))
             {
                 JHSNetworkClient.PushMessage(new JHSNetworkMessage()
                 {
                     msgType = msgType,
                     reader  = msgReader,
                     conn    = this
                 });
             }
             else
             {
                 if (NetConfig.logFilter >= JHSLogFilter.Error)
                 {
                     JHSDebug.LogError("JHSConnection :: Unknown message ID " + msgType + " connId:" + connectionId);
                 }
                 if (NetConfig.UseStatistics)
                 {
                     ReadError += 1;
                 }
             }
         }
         else
         {
             JHSNetworkReader          msgReader   = new JHSNetworkReader(msgBuffer);
             JHSNetworkMessageDelegate msgDelegate = null;
             if (m_MessageHandlersDict.ContainsKey(msgType))
             {
                 msgDelegate = m_MessageHandlersDict[msgType];
             }
             if (msgDelegate != null)
             {
                 msgDelegate(new JHSNetworkMessage()
                 {
                     msgType = msgType,
                     reader  = msgReader,
                     conn    = this
                 });
             }
             else
             {
                 if (NetConfig.logFilter >= JHSLogFilter.Error)
                 {
                     JHSDebug.LogError("JHSConnection :: Unknown message ID " + msgType + " connId:" + connectionId);
                 }
                 if (NetConfig.UseStatistics)
                 {
                     ReadError += 1;
                 }
             }
         }
     }
     catch { }
     return(true);
 }