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(); }
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(); }