public void Close(bool resetConnect) { Log.Debug("Proto Close"); if (client != null) { waitingPong = false; lastPingStartTime = 0; connectBack = null; connectBack1 = null; StopAllCoroutines(); client.Close(); recvLen = 0; IsServerConnet = false; if (resetConnect) { ResetConnectType(); } } }
public void ReStartTcpSocket(ConnectDelegate1 _connectback) { Log.Debug("打开一个tcp连接StartTcpSocket"); if (client == null) { client = new SocketLayer(); } else { Close(false); } connectBack = null; connectBack1 = _connectback; client.SetConnectCallback(ConnectBack); proto = new CProto(); recvBuf = new byte[BUFFER_SIZE * 64]; recvLen = 0; pingByte = new byte[] { (byte)CProto.PType.ping }; client.Connect(_host, _port); }
public void StartTcpSocket(string host, int port, SocketName name, ConnectDelegate _connectback) { Log.Debug("打开一个tcp连接StartTcpSocket"); _host = host; _port = port; if (client == null) { client = new SocketLayer(); } else { Close(true); } socketName = name; connectBack = _connectback; connectBack1 = null; client.SetConnectCallback(ConnectBack); proto = new CProto(); recvBuf = new byte[BUFFER_SIZE * 64]; recvLen = 0; pingByte = new byte[] { (byte)CProto.PType.ping }; client.Connect(host, port); }