예제 #1
0
 public void RegistReponseType(RpId rpId, ReponseDeserialization reponseDeserial)
 {
     if (mDeserializationFuncDic.ContainsKey(rpId))
     {
         Logger.LogError("注册重复的消息序列化方法 " + rpId.ToString());
         return;
     }
     mDeserializationFuncDic [rpId] = reponseDeserial;
 }
예제 #2
0
    /// <summary>
    /// 为网路底层准备的,逻辑层不能调用
    /// </summary>
    /// <param name="eventData">Event data.</param>
    public void OnEvent(EventData eventData)
    {
        RpId rpId = (RpId)eventData.Code;
        ReponseDeserialization deserializationFunc = null;

        if (mDeserializationFuncDic.TryGetValue(rpId, out deserializationFunc))
        {
            Logger.LogInfo("收到消息 " + rpId);
            ResponseBase responseMsg = deserializationFunc.Invoke(eventData.Parameters);
            if (null != responseMsg)
            {
                mReponseMessageList.Add(new ResponseMessageData(rpId, responseMsg));
            }
            else
            {
                Logger.LogError("消息解析失败 " + rpId);
            }
        }
        else
        {
            Logger.LogError("收到未注册的消息 " + rpId.ToString());
        }
    }