/** * 设置某个action不销毁 */ public void setActionForever(Api.ENetMsgId id) { if (!msgMap.ContainsKey(id)) { Debug.LogError("register handler of " + id + " first"); } msgMap[id].isOnce = false; }
public bool RegisterAction(Api.ENetMsgId id, System.Action <object> act) { if (!msgMap.ContainsKey(id)) { Debug.LogError("register handler of " + id + " first"); return(false); } msgMap[id].action = act; return(true); }
public bool RegisterHandler(Api.ENetMsgId id, MsgHandler handler) { if (msgMap.ContainsKey(id)) { Debug.LogError(id + " is already registered"); return(false); } Group g = new Group(); g.handler = new MsgHandler(handler); g.action = null; msgMap.Add(id, g); return(true); }
public bool InvokeHandler(Api.ENetMsgId id, byte[] data) { if (!msgMap.ContainsKey(id)) { Debug.LogError(id + " is not registered"); return(false); } Group g = msgMap[id]; object ret = g.handler(data); if (g.action != null) { g.action.Invoke(ret); g.action = null; } return(true); }