override public void OnMessage(USocket us, ByteBuffer bb) { try { int nDataSize = bb.ReadShort(); int nCheckCode = bb.ReadByte(); int nMsgVer = bb.ReadByte(); short nMainId = bb.ReadShort(); short nSubId = bb.ReadShort(); Debug.Log("<color=blue>" + string.Format("Message:{0},{1},{2},{3},{4}", nDataSize, nCheckCode, nMsgVer, nMainId, nSubId) + "</color>"); CMD_Base_RespNtf msg = _factory.CreateRespNtfMsg(new CMD_Command(nMainId, nSubId)); if (msg != null) { msg.Deserialize(bb, nDataSize); _queue.PushQueue(nMainId, nSubId, msg); } } catch (System.Exception ex) { Debug.LogError("<color=red>[Error]</color>---" + "KKBaseListener.OnMessage Error:" + ex.Message); } }
override public void OnError(USocket us, NetErrorCode eCode, int nSysErrorCode = -1, string err = "") { Debug.Log("<color=green>[log]KKBaseListener</color>---" + "OnError:" + eCode + ":" + nSysErrorCode + "->" + err); //MessageQueueHandler.PushError("On OnError " + nErrorCode + ":" + err); }
override public void OnOpen(USocket us) { Debug.Log("<color=green>[log]KKBaseListener</color>---" + "OnOpen"); //MessageQueueHandler.PushError("On OnOpen "); }
override public void OnClose(USocket us, bool fromRemote) { Debug.Log("<color=green>[log]KKBaseListener</color>---" + "OnClose"); //MessageQueueHandler.PushError("On Close + " + fromRemote); }
abstract public void OnOpen(USocket us);
abstract public void OnIdle(USocket us);
abstract public void OnClose(USocket us, bool fromRemote);
abstract public void OnMessage(USocket us, ByteBuffer bb);
// 处理错误,错误码为SocketCustomErrorCode // 如果eErrorCode 为 SocketCustomErrorCode.SystemCode 则nSysErrorCode有意义,表示系统Socket的错误 // extraInfo一般为调试输出信息 abstract public void OnError(USocket us, NetErrorCode eErrorCode, int nSysErrorCode = -1, string extraInfo = "");