public static void SetHandle(ServerGroupMessageType type, ServerGroupHandler handler) { if (group == null) { return; } if (handler == null) { group.handler.Remove(type); } else { group.handler[type] = handler; } }
void DoRecv(byte[] b, int sz) { BinaryFormatter formatter = new BinaryFormatter(); MemoryStream ms = new MemoryStream(b, 5, sz - 5, false); ServerGroupMessageType type = (ServerGroupMessageType)b[0]; if (!handler.Contains(type)) { return; } try { Hashtable msg = formatter.Deserialize(ms) as Hashtable; ServerGroupHandler h = (ServerGroupHandler)handler[type]; h(type, msg); } catch { } }
public static void SetHandle(ServerGroupMessageType type, ServerGroupHandler handler) { if(group==null)return; if(handler==null) group.handler.Remove(type); else group.handler[ type ]=handler; }