private void tcpCompletedMethod(TcpClient c, EnSocketAction enAction) { if (c.Client != null) { IPEndPoint iep = c.Client.RemoteEndPoint as IPEndPoint; string key = string.Format("{0}:{1}", iep.Address.ToString(), iep.Port); switch (enAction) { case EnSocketAction.Connect: //Console.WriteLine("已经与{0}建立连接", key); label2.Text = string.Format("已经与{0}建立连接", key); break; case EnSocketAction.SendMsg: Console.WriteLine("{0}:向{1}发送了一条消息", DateTime.Now, key); break; case EnSocketAction.Close: client.Close(); client = null; Console.WriteLine("服务端连接关闭"); this.Close(); Application.Exit(); break; default: break; } } else { Console.WriteLine("Tcp为空"); } }
public ClientFixture() { var options = new ClientOptions { Brokers = new[] { new BrokerAddress { Host = "localhost", Port = 9292 }, } }; Client = new ClientAsync(options); var tokenSource = new System.Threading.CancellationTokenSource(); tokenSource.CancelAfter(System.TimeSpan.FromMilliseconds(5000)); TimeoutToken = tokenSource.Token; }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Please run with an argument: server, serverasync, serverasyncoldsyntax, serverasyncoldsyntaxmanualreset, serverasyncnonblocking, client, clientasync"); } else if (args[0] == "server") { Server.Run(); } else if (args[0] == "serverasync") { ServerAsync.Run(); } else if (args[0] == "serverasyncoldsyntax") { ServerAsyncOldSyntax.Run(); } else if (args[0] == "serverasyncoldsyntaxmanualreset") { ServerAsyncOldSyntax.Run(); } else if (args[0] == "serverasyncnonblocking") { ServerAsyncNonblocking.Run(); } else if (args[0] == "client") { Client.Run(); } else if (args[0] == "clientasync") { ClientAsync.Run(); } else { Console.WriteLine("Please run with an argument: server, serverasync, serverasyncoldsyntax, serverasyncoldsyntaxmanualreset, serverasyncnonblocking, client, clientasync"); } Console.ReadLine(); }
/// <summary> /// On create instance of Client /// </summary> partial void OnCreated() { // Start the async control. _asyncClientContext = new ClientAsync(this); _asyncClientContext.AsyncError += new Nequeo.Threading.EventHandler <Exception>(AsyncEvent_AsyncError); }
public AddDeviceForm(ClientAsync client) { tcpClient = client; InitializeComponent(); }
public void Question_GetQuestions_Async() { ClientAsync.GetQuestions(questions => Assert.IsNotNull(questions), error => Assert.Fail()); }
public void Question_Search_Async() { ClientAsync.Search(questions => Assert.IsNotNull(questions), error => Assert.Fail(), inTitle: "Thread"); }
public void Question_GetQuestionTimeline_Async() { ClientAsync.GetQuestionTimeline(31415, events => Assert.IsNotNull(events), error => Assert.Fail()); }
public void Tag_GetTagsByUser_Async() { ClientAsync.GetTagsByUser(1464, tags => Assert.IsNotNull(tags), error => Assert.Fail()); }
public void Revision_GetRevision_Async() { ClientAsync.GetRevision(31415, Guid.Parse("5a1fd2ac-421a-43a9-a2a3-2e9b5afe1b23"), revision => Assert.IsNotNull(revision)); }
public void Revision_GetRevisions_Async() { ClientAsync.GetRevisions(31415, revisions => Assert.IsNotNull(revisions), error => Assert.Fail()); }