//链接服务器 static async void connect() { var result = client.Connect("127.0.0.1", 3000); //同步链接 // var (IsSuccess, Msg) = await client.ConnectAsync("127.0.0.1", 3000); //异步链接 Console.WriteLine(result); var fiberRw = await client.GetFiberRw(); await await fiberRw.Sync.Ask(() => { fiberRw.Write(1000); //登入 fiberRw.Write("test"); fiberRw.Write("password"); return(fiberRw.FlushAsync()); }); //for (; ; ) //我们也可以在这里处理数据 //{ // try // { // await ReadCommand(fiberRw); // } // catch (Exception er) // { // Console.WriteLine(er); // break; // } //} //fiberRw.Disconnect(); }
private async void LogOn() { LogOn logOnWin = new LogOn(); logOnWin.ShowDialog(); if (logOnWin.OK) { var fiberRw = await client.GetFiberRw(); fiberRw.Write(1000); fiberRw.Write(logOnWin.UserName); fiberRw.Write(logOnWin.PassWord); await fiberRw.Flush(); } else { this.Close(); } }