public virtual void CreateConnection(string ip, int port) { SocketConnectionFactory client = new SocketConnectionFactory(new SocketTransportOptions()); Unsafe.AsRef(_connection) = client.ConnectAsync(new IPEndPoint(IPAddress.Parse(ip), port)).Result; Unsafe.AsRef(_sender) = _connection.Transport.Output; Unsafe.AsRef(_reciver) = _connection.Transport.Input; Init(); RunReciver(); }
public NewRedisClient(IPEndPoint point) { _taskQueue = new ConcurrentQueue <TaskCompletionSource <string> >(); SocketConnectionFactory client = new SocketConnectionFactory(new SocketTransportOptions()); _connection = client.ConnectAsync(point).Result; _sender = _connection.Transport.Output; _reciver = _connection.Transport.Input; RunReciver(); }
public static async void Test(IPEndPoint endpoit) { // SAEA 被接口封装为异步状态机 详见:https://sharplab.io/#v2:D4AQTAjAsAUCAMACEECsBuWDkQHQCUBXAOwBcBLAWwFNcBhAe0oAdyAbagJwGUuA3cgGNqAZ0xwkKXABUAFp2oBDACbliAc3EgAzMjCI6iAN6xEZnADZkAFkQBZRWoAUKeAG0AuokWd1IgJSm5sEmMEHBEYgAosTKTv7ikZEoAJxOAEQgVrKKIogipD6k1MoAhOkJ4UlmjMQiDBwESsoA0tQAnvGJSQC+VcE6lsgAHDbRsfH95qHV5iApiMTUAO6I3AyCANbUpACCy46FAEYcUXzUZLu+Il1TZn1hMA+wsGrFnMSKbHprG9t7B3Ix1O50u10QAC4zABJOicIFCL4AOQYFAAZu1GCwOBQGMQqqE7ohmPC+IpikMFCo8Wx2jh9AB9QRfNhHRRbLHMHElRAAXkQ8T5AD5jIgeuIXjBqiTyGSKShGcy2Kz2ZsJY9qoN1lsdvtDooTtQzhc9uCAOK6wHvQW8kWkWTkMREwZHBgNRDQkSc7nKYWIfDUNFcC7CKIAR0IXxuTJZbK2ABpEDHlXHNt6diVKhqkoM3ogLaQAyJCGxSJMpUlQiAAOyICDdSLPbPJXQgWwAeWI6eKcQViEEeIoxEjuOIgQrkUJE9m5DRAoDQYUxFDEajTmTKoTSaVm7TTC5GeU/kQwGAROqC+Dy6Nq7YN2hZC4bD+JXo+58RoAHoIchpqE4FDnDdU0TAcyDUEdyDxRNh2VfxE2A1Vu0zcdZmmc8cwsAgSCcMCh0gvEszQ+5JWqJtNVbWwAFU6kUINO2Q3sIH0PCIPJKCxyJGZiIY/cfVwwc2NHIjelInNKIMPiM3LapuLQ3jsUPW5p2CcikhJVFqEEHsxgUg8exkysxLQslOH7QTh3YvE+Q9R9OGfHVlFwKJv1/dR/0A7dY1VBCd1TRiRLQ2cBVYyzR0QUp+VgthUOIuTiLMDDIgAemS1IMkAUuNADZTQAsf/SRAAGpxgHVQNFwKjpAAMWGXAC24Uh4Q0Jx7UdXAACFCDRRd/EC2YHjIyUqh6IA= // 其中 continuation 为异步状态机的 MoveNext 方法。 SocketConnectionFactory client = new SocketConnectionFactory(new SocketTransportOptions()); var connection = client.ConnectAsync(endpoit).Result; Input(connection); Output(connection); }
public NewRedisClient4(IPEndPoint point) { _protocalStart = (byte)43; SocketConnectionFactory client = new SocketConnectionFactory(new SocketTransportOptions()); _connection = client.ConnectAsync(point).Result; _sender = _connection.Transport.Output; _reciver = _connection.Transport.Input; _receiverQueue = new SourceConcurrentQueue2 <TaskCompletionSource <bool> >(_sender); RunReciver(); }
public NewRedisClient3(IPEndPoint point)//, ConcurrentStack<NewRedisClient3> pool) { _protocalStart = (byte)43; //_pool = pool; SocketConnectionFactory client = new SocketConnectionFactory(new SocketTransportOptions()); _connection = client.ConnectAsync(point).Result; _sender = _connection.Transport.Output; _reciver = _connection.Transport.Input; _receiverQueue = new SourceConcurrentQueue <Task <bool> >(_sender); RunReciver(); }
public NewRedisClient2(IPEndPoint point) { _protocalStart = (byte)43; _receiverQueue = new Queue <TaskCompletionSource <bool> >(); SocketConnectionFactory client = new SocketConnectionFactory(new SocketTransportOptions()); _connection = client.ConnectAsync(point).Result; _sender = _connection.Transport.Output; _reciver = _connection.Transport.Input; RunReciver(); //Task.Run(async () => { // await Task.Delay(30000); // Console.WriteLine(total); // Console.WriteLine(_receiverQueue.Count); // await Task.Delay(20000); // Console.WriteLine(total); // Console.WriteLine(_receiverQueue.Count); // await Task.Delay(10000); // Console.WriteLine(total); // Console.WriteLine(_receiverQueue.Count); //}); //RunSender(); }