/// <summary> /// �����p���D�n��k�]������^ /// </summary> /// <param name="sender">�b�۰ʩM��ʽs���Ȧs��Hashtable</param> public int getExecution(object sender) { //System.Collections.Generic.List<string> runThread = (System.Collections.Generic.List<string>)sender; ExecutionObj exObj = new ExecutionObj(); exObj.RspID = ht["INC_ID"].ToString(); exObj.EventID = ht["EVENTID"].ToString(); AEvent myEvent = factory(); if (myEvent == null) return -1; myEvent.produceExecution(exObj); lock (exObj) { EasyClient easy = new EasyClient(); easy.saveExecution(ht["INC_ID"].ToString(), Convert.ToInt32(ht["EVENTID"]), exObj, false); //saveExecution(exObj); } return Convert.ToInt32(exObj.EventID); //if (Execution.getBuilder() != null) //{ // switch (Convert.ToInt32(ht["INC_LOGIN_MODE"].ToString())) // { // case 1: // Execution.getBuilder().reportEvent(LoginMode.Auto, exObj.EventID); // break; // case 2: // Execution.getBuilder().reportEvent(LoginMode.Half, exObj.RspID); // break; // default: // Execution.getBuilder().reportEvent(LoginMode.Manual, exObj.RspID); // break; // } //} //runThread.Remove(ht["INC_ID"].ToString()); }
public async Task TestConnectRepeat() { var client = new EasyClient(); client.Initialize(new FakeReceiveFilter(), (p) => { // do nothing }); Console.WriteLine("Connecting"); var ret = await client.ConnectAsync(new DnsEndPoint("github.com", 443)); Console.WriteLine("Connected"); Assert.True(ret); Console.WriteLine("Closing"); await client.Close(); Console.WriteLine("Closed"); Console.WriteLine("Connecting"); ret = await client.ConnectAsync(new DnsEndPoint("github.com", 443)); Console.WriteLine("Connected"); Assert.True(ret); Console.WriteLine("Closing"); await client.Close(); Console.WriteLine("Closed"); }
public async Task TestConnection() { var client = new EasyClient(); client.Initialize(new FakeReceiveFilter(), (p) => { // do nothing }); var ret = await client.ConnectAsync(new DnsEndPoint("github.com", 443)); Assert.True(ret); }
public async Task TestGet() { var client = new EasyClient(); //client.Security = new SecurityOption(); //client.Security.AllowUnstrustedCertificate = true; //client.Security.AllowNameMismatchCertificate = true; client.Error += (s, e) => { Console.WriteLine(e.Exception.Message); }; var taskCompleteSrc = new TaskCompletionSource<HttpPackageInfo>(); client.Initialize(new HttpReceiveFilter(), (p) => { taskCompleteSrc.SetResult(p); }); var ret = await client.ConnectAsync(new DnsEndPoint("www.supersocket.net", 80)); Assert.True(ret); Console.WriteLine("Get https connection established"); var sb = new StringBuilder(); sb.AppendLine("GET / HTTP/1.1"); sb.AppendLine("Accept: text/html, application/xhtml+xml, image/jxr, */*"); sb.AppendLine("Host: www.supersocket.net"); sb.AppendLine("Connection: Keep-Alive"); sb.AppendLine(); var data = Encoding.ASCII.GetBytes(sb.ToString()); client.Send(new ArraySegment<byte>(data, 0, data.Length)); var response = await taskCompleteSrc.Task; Console.WriteLine(response.Body); }
public void EasyClient() { var client = new EasyClient("http://localhost:8080"); client.Invoke("HelloWorld", "Alex"); }
public async Task TestCommandLine(Type hostConfiguratorType) { var hostConfigurator = CreateObject <IHostConfigurator>(hostConfiguratorType); using (var server = CreateSocketServerBuilder <StringPackageInfo, CommandLinePipelineFilter>(hostConfigurator) .UseCommand((options) => { options.AddCommand <SORT>(); }).BuildAsServer()) { Assert.Equal("TestServer", server.Name); Assert.True(await server.StartAsync()); OutputHelper.WriteLine("Server started."); IEasyClient <StringPackageInfo> client; var services = new ServiceCollection(); services.AddLogging(); services.Configure <ILoggingBuilder>((loggingBuilder) => { loggingBuilder.AddConsole(); }); var sp = services.BuildServiceProvider(); var loggerFactory = sp.GetService <ILoggerFactory>(); var logger = loggerFactory.CreateLogger("Client"); var pipelineFilter = new CommandLinePipelineFilter { Decoder = new DefaultStringPackageDecoder() }; if (hostConfigurator.IsSecure) { client = (new SecureEasyClient <StringPackageInfo>(pipelineFilter, logger)).AsClient(); } else { client = new EasyClient <StringPackageInfo>(pipelineFilter, logger).AsClient(); } StringPackageInfo package = null; client.PackageHandler += (s, p) => { package = p; }; var connected = await client.ConnectAsync(new IPEndPoint(IPAddress.Loopback, hostConfigurator.Listener.Port)); Assert.True(connected); client.StartReceive(); await client.SendAsync(Utf8Encoding.GetBytes("SORT 10 7 3 8 6 43 23\r\n")); await Task.Delay(1000); Assert.NotNull(package); Assert.Equal("SORT", package.Key); Assert.Equal("3 6 7 8 10 23 43", package.Body); await client.CloseAsync(); await server.StopAsync(); } }
public TcpClientInfo(PackJson packJson, EasyClient <NatPackageInfo> natClient) { PackJson = packJson; NatClient = natClient; Init(); }
public Startup(ILogger <Startup> logger, IConfiguration config, EasyClient client) { _logger = logger; _config = config; _client = client; }