public StreamSock Connect(string ip, int port, Action connect_callback) { StreamSock sock = new StreamSock(); sock.Connect(ip, port, connect_callback); this.AddSock(sock); return(sock); }
public virtual void SockConnect(string ip, int port, int channel, Action callback, Action disconnected = null) { SockMsgRouter router = GetRouter(channel); StreamSock sock = sockMgr.Connect(ip, port, callback); sock.Router = router; router.ClearBuff(false); sock.socketDisconnection += disconnected; }
public void Disconnect(StreamSock sock) { if (sock == null) { return; } // this.RemoveSock(sock); removeList.Add(sock); sock.Close(); }
private void RemoveSock(StreamSock sock) { if (sock == null) { return; } lock (((ICollection)sockList).SyncRoot) { if (sockList.Contains(sock)) { sockList.Remove(sock); } } }