private KCPProxy GetKcp(IPEndPoint ipep, bool autoAdd = true) { if (!IsValidKcpIPEndPoint(ipep)) { return(null); } KCPProxy proxy = null; int cnt = m_ListKcp.Count; for (int i = 0; i < cnt; i++) { proxy = m_ListKcp[i]; if (proxy.RemotePoint.Equals(ipep)) { return(proxy); } } if (autoAdd) { proxy = new KCPProxy(m_KcpKey, ipep, m_SystemSocket); proxy.AddReceiveListener(OnReceiveAny); m_ListKcp.Add(proxy); } return(proxy); }
//================================================================================= #region 接收逻辑 public void AddReceiveListener(IPEndPoint remotePoint, KCPReceiveListener listener) { KCPProxy proxy = GetKcp(remotePoint); if (proxy != null) { proxy.AddReceiveListener(listener); } else { m_AnyEPListener += listener; } }