示例#1
0
 /// <summary>
 /// 注册要接收的消息
 /// 具体的一个Netback可以含有有多条消息,Netback初始化时,要把自身所有消息注册到这里
 ///
 /// </summary>
 /// <param name="msgID">Message I.</param>
 /// <param name="back">Back.</param>
 public void RegistMsg(int msgID, AbsNetBack back)
 {
     if (NetBackAnalyzerDic.ContainsKey(msgID))
     {
         NetBackAnalyzerDic [msgID] = back;
     }
     else
     {
         NetBackAnalyzerDic.Add(msgID, back);
     }
 }
示例#2
0
    /// <summary>
    /// 收到消息
    /// </summary>
    /// <param name="__msgCode">消息号</param>
    /// <param name="__msgContent">消息体</param>
    private static void AnalysisCache4RecMsg(int __msgCode, byte[] __msgContent)
    {
        if (NetBackMgr.GetInst().NetBackAnalyzerDic.ContainsKey(__msgCode))
        {
            AbsNetBack back = NetBackMgr.GetInst().NetBackAnalyzerDic [__msgCode];

            MemoryStream tstream = new MemoryStream(__msgContent);
            back._BinaryReader = new BinaryReader(tstream, Encoding.UTF8);
            Type       t    = back.GetType();
            MethodInfo info = t.GetMethod("Recevie" + __msgCode);
            info.Invoke(back, null);
            back._BinaryReader.Close();
            tstream.Close();
            tstream.Dispose();
        }
        else
        {
            Debug.LogError("无法解析Socket包:" + __msgCode);
        }
    }