public void Update() { while (__receiveMsgQueue.Count != 0) { var msg = __receiveMsgQueue.Dequeue(); if (msg.type == MessageType.MSG_RESPONSE) { UnityEngine.Debug.Log("<<< Receive: " + msg.route + " data: " + msg.jsonObj.ToString()); UnityEngine.Debug.Assert(_eventManager._GetCallbackCount() != 0); _eventManager.InvokeCallBack(msg.id, msg); _eventManager.RemoveCallback(msg.id); } else if (msg.type == MessageType.MSG_PUSH) { UnityEngine.Debug.Log("<<< Receive event: " + msg.route + " data: " + msg.jsonObj.ToString()); _eventManager.InvokeOnEvent(msg.route, msg); } else if (msg.type == MessageType.MSG_SYS) { if (msg.id != 0) { _eventManager.InvokeCallBack(msg.id, msg); _eventManager.RemoveCallback(msg.id); } else { _eventManager.InvokeOnEvent(msg.route, msg); } } } }
public void poll() { lock (guard) { foreach (Message msg in msgQueue) { if (msg.type == MessageType.MSG_RESPONSE) { try { eventManager.InvokeCallBack(msg.id, msg.data); } catch (Exception e) { Debug.Log("InvokeCallback exception: " + e.ToString()); Debug.Log("id=" + msg.id + " data: " + msg.data.ToString()); } } else if (msg.type == MessageType.MSG_PUSH) { try { eventManager.InvokeOnEvent(msg.route, msg.data); } catch (Exception e) { Debug.Log("InvokeOnEvent exception: " + e.ToString()); Debug.Log("route=" + msg.route + " data: " + msg.data.ToString()); } } } msgQueue.Clear(); } }
internal void processMessage(Message msg) { if (msg.type == MessageType.MSG_RESPONSE) { eventManager.InvokeCallBack(msg.id, msg.data); } else if (msg.type == MessageType.MSG_PUSH) { eventManager.InvokeOnEvent(msg.route, msg.data); } }
public void Update() { while (__receiveMsgQueue.Count != 0) { var msg = __receiveMsgQueue.Dequeue(); if (msg.type == MessageType.MSG_RESPONSE) { UnityEngine.Debug.Log("<color=green><<< Receive: </color>" + msg.route + " data: " + msg.rawString); ///UnityEngine.Debug.Assert(_eventManager._GetCallbackCount() != 0); if (OnRPCReturn != null) { OnRPCReturn(msg.id); } _eventManager.InvokeCallBack(msg.id, msg); _eventManager.RemoveCallback(msg.id); } else if (msg.type == MessageType.MSG_PUSH) { UnityEngine.Debug.Log("<color=blue><<< Receive event:</color> " + msg.route + " data: " + msg.rawString); _eventManager.InvokeOnEvent(msg.route, msg); } else if (msg.type == MessageType.MSG_SYS) { if (msg.id != 0) { _eventManager.InvokeCallBack(msg.id, msg); _eventManager.RemoveCallback(msg.id); } else { _eventManager.InvokeOnEvent(msg.route, msg); } } } }
internal void processMessage(Message msg) { if (msg.type == MessageType.MSG_RESPONSE) { //msg.data["__route"] = msg.route; //msg.data["__type"] = "resp"; eventManager.InvokeCallBack(msg.id, msg.data); } else if (msg.type == MessageType.MSG_PUSH) { //msg.data["__route"] = msg.route; //msg.data["__type"] = "push"; eventManager.InvokeOnEvent(msg.route, msg.data); } }
public void poll() { lock (guard) { foreach (var msg in msgQueue) { if (msg.type == MessageType.MSG_RESPONSE) { eventManager.InvokeCallBack(msg.id, msg.data); } else if (msg.type == MessageType.MSG_PUSH) { eventManager.InvokeOnEvent(msg.route, msg.data); } } msgQueue.Clear(); if (this.bConnectCallBack == true) { if (connectCB != null) { connectCB(); } this.bConnectCallBack = false; } if (this.handShakeCallBackCanCall == true) { this.handShakeCallBack(this.handShakeCallBackData); this.handShakeCallBackCanCall = false; } if (this.bDisconnCallBack == true) { if (disconnectCB != null) { disconnectCB(); } this.bDisconnCallBack = false; } } }
internal void processMessage(Message msg) { //try //{ if (msg.type == MessageType.MSG_RESPONSE) { //msg.data["__route"] = msg.route; //msg.data["__type"] = "resp"; eventManager.InvokeCallBack(msg.id, msg.data); } else if (msg.type == MessageType.MSG_PUSH) { //msg.data["__route"] = msg.route; //msg.data["__type"] = "push"; eventManager.InvokeOnEvent(msg.route, msg.data); } //} //catch (Exception e) //{ // UnityEngine.Debug.LogError(e.Message); //} }
public void Update() { while (__receiveMsgQueue.Count != 0) { lock (__receiveMsgQueue) { var msg = __receiveMsgQueue.Dequeue(); if (msg.type == MessageType.MSG_RESPONSE) { //msg.data["__route"] = msg.route; //msg.data["__type"] = "resp"; eventManager.InvokeCallBack(msg.id, msg); } else if (msg.type == MessageType.MSG_PUSH) { //msg.data["__route"] = msg.route; //msg.data["__type"] = "push"; eventManager.InvokeOnEvent(msg.route, msg); } } } }
public void update() { while (receiveMsgQueue.Count != 0) { var msg = receiveMsgQueue.Dequeue(); if (msg == null) { continue; } if (msg.type == MessageType.MSG_RESPONSE) { //msg.data["__route"] = msg.route; //msg.data["__type"] = "resp"; eventManager.InvokeCallBack(msg.id, msg.data); eventManager.RemoveCallBack(msg.id); } else if (msg.type == MessageType.MSG_PUSH) { //msg.data["__route"] = msg.route; //msg.data["__type"] = "push"; eventManager.InvokeOnEvent(msg.route, msg.data); } } }