//处理消息 private void HandleMsg(Conn conn, ProtocolBase protocolBase) { string name = protocolBase.GetName(); string methodName = "Msg" + name; //连接协议分发 if (conn.player == null || name == "HeatBeat" || name == "Logout") { MethodInfo mm = handleConnMsg.GetType().GetMethod(methodName); if (mm == null) { string str = "[警告]HandleMsg没有处理连接方法:"; Console.WriteLine(str + methodName); return; } Object[] obj = new object[] { conn, protocolBase }; Console.WriteLine("[处理连接消息]" + conn.GetAddress() + ":" + name); mm.Invoke(handleConnMsg, obj); } //角色协议分发 else { MethodInfo mm = handlePlayerMsg.GetType().GetMethod(methodName); if (mm == null) { string str = "[警告]HandleMsg没有处理玩家方法:"; Console.WriteLine(str + methodName); return; } Object[] obj = new object[] { conn.player, protocolBase }; Console.WriteLine("[处理玩家消息]" + conn.player.id + ":" + name); mm.Invoke(handlePlayerMsg, obj); } }
public bool Send(ProtocolBase protocol, MsgDistribution.Delegate cb) { string cbName = protocol.GetName(); Debug.Log(cbName); return(Send(protocol, cbName, cb)); }
void HandleMsg(Conn conn, ProtocolBase protoBase) { string name = protoBase.GetName(); string methodName = "Msg" + name; if (conn.status == Conn.Status.Connected || name == "HeartBeat" || name == "Logout") { //登录相关的消息处理 MethodInfo mm = ServNet.instance.handleConnMsg.GetType().GetMethod(methodName); if (mm == null) { Console.WriteLine("[警告]HandleConnMsg未定义处理连接相关的方法:" + methodName); return; } Object[] obj = new object[] { conn, protoBase }; //Console.WriteLine("[处理连接相关消息]" + conn.GetAddress() + "发起的" + methodName); mm.Invoke(ServNet.instance.handleConnMsg, obj); } else { //游戏逻辑相关的消息处理 MethodInfo mm = ServNet.instance.handlePlayerMsg.GetType().GetMethod(methodName); if (mm == null) { Console.WriteLine("[警告]HandlePlayerMsg未定义处理游戏逻辑相关的方法:" + methodName); return; } Object[] obj = new object[] { conn.player, protoBase }; //Console.WriteLine("[处理游戏逻辑相关消息]" + conn.GetAddress() + "发起的" + methodName); mm.Invoke(ServNet.instance.handlePlayerMsg, obj); } }
public void DispatchMsgEvent(ProtocolBase protocol) { if (protocol == null) { return; } string name = protocol.GetName(); MethodInfo mm = handleClientMsg.GetType().GetMethod(name); if (mm != null) { object[] obj = new object[] { protocol }; mm.Invoke(handleClientMsg, obj); } if (eventDict.ContainsKey(name)) { eventDict[name](protocol); } if (onceDict.ContainsKey(name)) { onceDict[name](protocol); onceDict[name] = null; onceDict.Remove(name); } }
private void HandleMsg(ClientPeer conn, ProtocolBase protoBase) { string name = protoBase.GetName(); string methodName = "Msg" + name; //连接协议分发 //if (conn.player == null || name == "HeatBeat" || name == "Logout") //{ // MethodInfo mm = handleConnMsg.GetType().GetMethod(methodName); // if (mm == null) // { // string str = "[警告]HandleMsg没有处理连接方法 "; // Console.WriteLine(str + methodName); // return; // } // Object[] obj = new object[] { conn, protoBase }; // Console.WriteLine("[处理链接消息]" + conn.GetAdress() + " :" + name); // mm.Invoke(handleConnMsg, obj); //} ////角色协议分发 //else //{ // MethodInfo mm = handlePlayerMsg.GetType().GetMethod(methodName); // if (mm == null) // { // string str = "[警告]HandleMsg没有处理玩家方法 "; // Console.WriteLine(str + methodName); // return; // } // Object[] obj = new object[] { conn.player, protoBase }; // Console.WriteLine("[处理玩家消息]" + conn.player.id + " :" + name); // mm.Invoke(handlePlayerMsg, obj); //} }
//处理消息 private void HandleMsg(Conn conn, ProtocolBase protobBase) { string name = protobBase.GetName(); MethodInfo mm = handleServerMsg.GetType().GetMethod(name); if (mm == null) { //HandleMsg没有对应方法 return; } Object[] obj = new object[] { conn, protobBase }; mm.Invoke(handleServerMsg, obj); }
//消息分发 public void DispatchMsgEvent(ProtocolBase protocol) { string name = protocol.GetName(); //Debug.Log("分发处理消息 " + name); if (eventDict.ContainsKey(name)) { eventDict[name](protocol); } if (onceDict.ContainsKey(name)) { onceDict[name](protocol); onceDict[name] = null; onceDict.Remove(name); } }
//处理单条协议 public void DispatchMsgEvent(ProtocolBase protocol) { string protoName = protocol.GetName(); Console.WriteLine("分发消息 " + protoName); if (eventDict.ContainsKey(protoName)) { eventDict[protoName](protocol); } if (onceDict.ContainsKey(protoName)) { onceDict[protoName](protocol); //onceDict[protoName] = null; //没必要 onceDict.Remove(protoName); } }
void DispatchMsgEvent(ProtocolBase protoBase) { string name = protoBase.GetName(); Console.WriteLine("[MsgDistribution.DispatchMsgEvent] Dispatch protocol: " + name); if (eventDict.ContainsKey(name)) { eventDict [name] (protoBase); } if (onceDict.ContainsKey(name)) { onceDict [name] (protoBase); onceDict [name] = null; onceDict.Remove(name); } }
private void DispatchMsgEvent(ProtocolBase protocol) { //throw new NotImplementedException(); string name = protocol.GetName(); Debug.Log("消息分发处理" + name); if (eventDict.ContainsKey(name)) { eventDict[name](protocol); } if (onceDict.ContainsKey(name)) { onceDict[name](protocol); onceDict[name] = null; onceDict.Remove(name); } }
private void HandleMsg(ProtocolBase protocolBase) { Debug.Log("客户端-> HandleMsg 开始执行!"); if (protocolBase != null) { Debug.Log("客户端-> HandleMsg -> protoName=" + protocolBase.GetName()); } ProtocolBytes proto = (ProtocolBytes)protocolBase; //获取数值 int start = 0; string protoName = proto.GetString(start, ref start); int ret = proto.GetInt(start, ref start); //显示 //Debug.Log("接收" + proto.GetDesc()); recvStr = "接收" + proto.GetName() + " " + ret.ToString(); }
public bool Send(ProtocolBase protocol, MsgDistribution.Delegate cb) { string name = protocol.GetName(); return(Send(protocol, cb, name)); }
public bool Send(ProtocolBase protocol, MsgDistribution.Delegate cb) //消息监听 { string cbName = protocol.GetName(); return(Send(protocol, cbName, cb)); }
public void Send(ProtocolBase protocol, Delegate cb) { string cbName = protocol.GetName(); Send(protocol, cbName, cb); }