public async void ConnectServer()
        {
            TcpClient client = new TcpClient();

            mChannel = new NetChannel();

            await client.ConnectAsync("127.0.0.1", 10998);

            mChannel.Init(client);
            mChannel.AddListener(OnReceive);
            mChannel.StartReceive();
        }
Exemple #2
0
        public async void Connect(ServerConfig svrCfg, Action callback)
        {
            DisconnectPreviousSvr();

            TcpClient client = new TcpClient();

            mChannel = new NetChannel();
            mChannel.AddListener(mUnityMsgDispatcher.OnReceive);

            await client.ConnectAsync(svrCfg.host, svrCfg.port);

            mChannel.Init(client);

            mChannel.StartReceive();
            //todo start heart beat

            callback?.Invoke();
        }