public async virtual Task StartAsync(CancellationToken cancellationToken) { plaintextResult = new StringBytes(_helloWorldPayload); mApiServer = new HttpApiServer(); mApiServer.Options.Port = 8080; mApiServer.Options.BufferPoolMaxMemory = 500; mApiServer.Options.MaxConnections = 100000; mApiServer.Options.Statistical = false; mApiServer.Options.UrlIgnoreCase = false; mApiServer.Options.LogLevel = BeetleX.EventArgs.LogType.Error; mApiServer.Options.LogToConsole = true; mApiServer.Options.PrivateBufferPool = true; mApiServer.Register(typeof(Program).Assembly); HeaderTypeFactory.SERVAR_HEADER_BYTES = Encoding.ASCII.GetBytes("Server: TFB\r\n"); mApiServer.HttpConnected += (o, e) => { e.Session["DB"] = new RawDb(new ConcurrentRandom(), Npgsql.NpgsqlFactory.Instance); }; mApiServer.Open(); RawDb._connectionString = "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4;Multiplexing=true;Write Coalescing Delay Us=500;Write Coalescing Buffer Threshold Bytes=1000"; //RawDb._connectionString = "Server=192.168.2.19;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=3"; System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(); var response = await client.GetAsync("http://localhost:8080/json"); mApiServer.BaseServer.Log(LogType.Info, null, $"Get josn {response.StatusCode}"); response = await client.GetAsync("http://localhost:8080/plaintext"); mApiServer.BaseServer.Log(LogType.Info, null, $"Get plaintext {response.StatusCode}"); }
public void ShouldDeserializeDictionaryOfListOfDictionary() { var dict = new Dictionary <string, object>(); var dict2 = new Dictionary <string, object>(); var list = new List <object>(); dict2.Add(StringValue, Float32Value); list.Add(Int64Value); list.Add(dict2); dict.Add(SmallCharValue.ToString(), list); var bytes = new List <byte>(); bytes.Add(UbJsonCommon.ObjectStartMarker); bytes.AddRange(SmallCharStringBytes.Skip(1)); bytes.Add(UbJsonCommon.ArrayStartMarker); bytes.AddRange(Int64Bytes); bytes.Add(UbJsonCommon.ObjectStartMarker); bytes.AddRange(StringBytes.Skip(1)); bytes.AddRange(Float32Bytes); bytes.Add(UbJsonCommon.ObjectEndMarker); bytes.Add(UbJsonCommon.ArrayEndMarker); bytes.Add(UbJsonCommon.ObjectEndMarker); Assert.That(_deserializer.Deserialize(bytes.ToArray()), Is.EqualTo(dict)); }
public async virtual Task StartAsync(CancellationToken cancellationToken) { plaintextResult = new StringBytes(_helloWorldPayload); mApiServer = new HttpApiServer(); mApiServer.Options.Port = 8080; mApiServer.Options.BufferPoolMaxMemory = 500; mApiServer.Options.MaxConnections = 100000; mApiServer.Options.Statistical = false; mApiServer.Options.UrlIgnoreCase = false; mApiServer.Options.LogLevel = BeetleX.EventArgs.LogType.Error; mApiServer.Options.LogToConsole = true; mApiServer.Options.PrivateBufferPool = true; mApiServer.Register(typeof(Program).Assembly); mApiServer.HttpConnected += (o, e) => { e.Session["DB"] = new RawDb(new ConcurrentRandom(), Npgsql.NpgsqlFactory.Instance); }; mApiServer.Open(); System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(); var response = await client.GetAsync("http://localhost:8080/json"); mApiServer.BaseServer.Log(LogType.Info, null, $"Get josn {response.StatusCode}"); response = await client.GetAsync("http://localhost:8080/plaintext"); mApiServer.BaseServer.Log(LogType.Info, null, $"Get plaintext {response.StatusCode}"); }
public async virtual Task StartAsync(CancellationToken cancellationToken) { plaintextResult = new StringBytes(_helloWorldPayload); mApiServer = new HttpApiServer(); mApiServer.Options.Port = 8080; mApiServer.Options.BufferPoolMaxMemory = 500; mApiServer.Options.MaxConnections = 100000; mApiServer.Options.Statistical = false; mApiServer.Options.LogLevel = BeetleX.EventArgs.LogType.Error; mApiServer.Options.LogToConsole = true; mApiServer.Register(typeof(Program).Assembly); HeaderTypeFactory.SERVAR_HEADER_BYTES = Encoding.ASCII.GetBytes("Server: TFB\r\n"); mApiServer.HttpConnected += (o, e) => { e.Session["DB"] = new RawDb(new ConcurrentRandom(), Npgsql.NpgsqlFactory.Instance); }; mApiServer.Started += (o, e) => { mComplete.TrySetResult(new object()); }; mApiServer.Open(); RawDb._connectionString = "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4;Multiplexing=true;Write Coalescing Delay Us=500;Write Coalescing Buffer Threshold Bytes=1000"; //RawDb._connectionString = "Server=192.168.2.19;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=3"; await mComplete.Task; }
public static void Main(string[] args) { plaintextResult = new StringBytes(_helloWorldPayload); var builder = new HostBuilder() .ConfigureServices((hostContext, services) => { services.AddHostedService <BeetleXHttpServer>(); }); builder.Build().Run(); }
public void StringTest() { ServerSocketOne sso = new ServerSocketOne(); Socket s = sso.StartHost(); StringBytes sb = new StringBytes(s); try { sb.Recived += PrintString; } catch (Exception) { } }
public void StringTest() { ClientSocket cs = new ClientSocket(); Socket s = cs.ConnectToServer(); StringBytes sb = new StringBytes(s); sb.Send("test1"); Thread.Sleep(50); sb.Send("test2"); Thread.Sleep(50); sb.Send("test3"); Thread.Sleep(50); sb.Send("test4"); }
public virtual Task StartAsync(CancellationToken cancellationToken) { plaintextResult = new StringBytes(_helloWorldPayload); mApiServer = new HttpApiServer(); mApiServer.Options.Port = 8080; mApiServer.Options.BufferPoolMaxMemory = 500; mApiServer.Options.MaxConnections = 100000; mApiServer.Options.Statistical = false; mApiServer.Options.UrlIgnoreCase = false; mApiServer.Options.LogLevel = BeetleX.EventArgs.LogType.Error; mApiServer.Options.LogToConsole = true; mApiServer.Options.PrivateBufferPool = true; mApiServer.Register(typeof(Program).Assembly); mApiServer.Open(); return(Task.CompletedTask); }