void Start() { EventManagement.EventManager.Instance.registerCallbackForEvent("ReceiveMessageFromServer", (System.EventArgs e) => { NetworkWrapper.ReceiveMessageFromServerArgs args = e as NetworkWrapper.ReceiveMessageFromServerArgs; Debug.Log(args.messageData); }); }
/// <summary> /// Callback for WebSocket.onMessage /// extracts the message type and data from the packet and sends it to the event pipeline /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void onMessage(object sender, MessageEventArgs e) { ReceiveMessageFromServerArgs args = new ReceiveMessageFromServerArgs() { messageType = extractMessageType(e.Data), messageData = extractMessageData(e.Data) }; //ignore the session id message if (args.messageType == "sid") { return; } EventManager.Instance.triggerEvent("ReceiveMessageFromServer", args); }