Ejemplo n.º 1
0
    public bool StopService()
    {
        serviceState = ENetServiceState.Stop;

        if (_socketCon != null)
        {
            _socketCon.Close();
            _socketCon = null;
        }

        return(true);
    }
Ejemplo n.º 2
0
    //连接服务器
    private bool Connect()
    {
        acceptNet = true;

        StopService();

        _socketCon = new SocketConnect(host, port);

        if (_socketCon.Open())
        {
            Debug.Log("连接服务器成功!");

            serviceState = ENetServiceState.Running;

            thread = new Thread(new ThreadStart(CheckReceive));
            thread.Start();

            return(true);
        }
        Debug.LogError("连接服务器失败!");
        return(false);
    }