/// <summary> /// Get a single instance of type 'NetworkEventProcessor' /// </summary> /// <returns></returns> public static NetworkEventProcessor GetInstance() { if (m_Instance == null) { m_Instance = new NetworkEventProcessor(); } return(m_Instance); }
//public GTModuleListenerControl() //{ // mGlobalEventManager = GlobalEventManager.GetSingleton(); // mNetMsgEventManager = NetWorkEventManager.GetSingleton(); //} public GTModuleListenerControl(GTModel varModel) { mModel = varModel; if (varModel != null) { varModel.AddListener(this); } mGlobalMsgQueue = new EventHandlerQueue(CrossContextEventProcessor.GetInstance()); mNetMsgQueue = new EventHandlerQueue(NetworkEventProcessor.GetInstance()); mGlobalEventManager = CrossContextEventProcessor.GetInstance(); mNetMsgEventManager = NetworkEventProcessor.GetInstance(); }
public void Update() { if (m_Socket != null) { if (m_Socket.NeedCallConnected && m_Socket.OnConnectCallback != null) { m_Socket.NeedCallConnected = false; m_Socket.OnConnectCallback(); } else if (m_Socket.NeedCallDisconnected && m_Socket.OnDisconnectCallback != null) { m_Socket.NeedCallDisconnected = false; m_Socket.OnDisconnectCallback(); return; } if (m_Socket.m_NeedClose) { m_Socket.Close(); return; } if (m_Socket.IsConnected) { if (m_PacketsBuffer.Count != 0) { m_PacketsBuffer.Clear(); } m_Socket.GetAllReveivePackets(out m_PacketsBuffer); if (m_PacketsBuffer != null && m_PacketsBuffer.Count != 0) { for (int i = 0; i < m_PacketsBuffer.Count; i++) { NetPacket packet = m_PacketsBuffer[i]; if (packet != null) { NetworkEventProcessor.GetInstance().Notify(new EventEX <NetPacket>(packet.GetMessageID(), packet)); } } m_PacketsBuffer.Clear(); } } } if (m_ConnectionStateListener != null) { m_ConnectionStateListener.OnUpdate(this); } }