public void Update() { while (mxEvents.Count > 0) { lock (mxEvents) { NFNetEventType eventType = mxEvents.Dequeue(); NFNetEventParams eventParams = new NFNetEventParams(); eventParams.eventType = eventType; eventParams.client = this; eventParams.socket = mxClient; if (eventType == NFNetEventType.Connected) { mxNetListener.OnClientConnect(eventParams); } else if (eventType == NFNetEventType.Disconnected) { mxNetListener.OnClientDisconnect(eventParams); mxReader.Close(); mxWriter.Close(); mxClient.Close(); } else if (eventType == NFNetEventType.DataReceived) { lock (mxPackets) { eventParams.packet = mxPackets.Dequeue(); mxNetListener.OnDataReceived(eventParams); } } else if (eventType == NFNetEventType.ConnectionRefused) { } } } }
private void NetEventDelegation(NFNetEventType eventType) { Debug.Log(Time.realtimeSinceStartup.ToString() + " " + eventType.ToString()); switch (eventType) { case NFNetEventType.Connected: mEventModule.DoEvent((int)NFLoginModule.Event.Connected); break; case NFNetEventType.Disconnected: mEventModule.DoEvent((int)NFLoginModule.Event.Disconnected); break; case NFNetEventType.ConnectionRefused: mEventModule.DoEvent((int)NFLoginModule.Event.ConnectionRefused); break; default: break; } }