void Update() { MSG.MSGEvent e = null; PlayerPrefs.SetString("m_MSG_LogLevel", m_MSG_LogLevel.ToString()); m_discon_uid_list.Clear(); foreach (var v in m_mapMSGClient) { nNWM.nDummy.NetEventPlugin plugin = v.Value; MSG.MSGClient client = plugin.m_MSGClient; if (client == null) { continue; } while (client.PopEvent(out e)) { switch (e.EventType) { case MSG.MSGEventType.Connected: plugin.NetLog("[Net] On Connect : " + plugin.db_id(), true); //nNWM.nUtil.jDumper.NamedDump(e)); plugin.OnConnect(); break; case MSG.MSGEventType.Disconnected: plugin.NetLog("[Net] On Disconnect", true); // + nNWM.nUtil.jDumper.NamedDump(e),true); plugin.OnDisconnect(); plugin.m_MSGClient = null; //m_discon_uid_list.Add(plugin.db_id()); break; case MSG.MSGEventType.RecvMessage: onRecvFromUG(plugin, e); break; default: plugin.NetError("[Net] Unkown MSGEventType : " + e.EventType.ToString() + " : " + nNWM.nUtil.jDumper.NamedDump(e)); break; } } if (e != null) { client.InsertEventToRecyclingPool(e); } } //foreach (var v in m_mapMSGClient) // foreach(var uid in m_discon_uid_list) // { // m_mapMSGClient.Remove(uid); // } } //void FixedUpdate ()
public void Logout(nNWM.nDummy.NetEventPlugin plugin) { if (plugin == null) { Debug.LogWarning("Logout : plugin ==null"); return; } MSG.MSGClient client = plugin.m_MSGClient; if (client == null) { Debug.LogWarning("client ==null"); return; } if (client.IsConnected) { client.Close(true); } }
public void Login(string ip, int port, nNWM.nDummy.NetEventPlugin plugin, MSG.Logger logger = null) { user_id_t uid = plugin.db_id(); bool isExist = false; if (m_mapMSGClient.ContainsKey(uid) == true) { if (plugin.m_MSGClient != null) { plugin.NetError(" already logined. Do \"@user.logout " + uid + "\""); return; } isExist = true; } if (logger == null) { logger = new nNWM.nDummy.DummyClientLogger(); } MSG.MSGClient client = new MSG.MSGClient(uid.ToString(), logger); client.LogLevel = m_MSG_LogLevel; plugin.m_MSGClient = client; try { bool isOk = plugin.m_MSGClient.Connect(ip, port); if (!isOk) { plugin.NetError(" Login Fail"); return; } } catch (System.Exception ex) { plugin.NetError("Login : " + ex.ToString()); return; } if (isExist == false) { m_mapMSGClient.Add(uid, plugin); } }