Beispiel #1
0
        public async static Task SendData(int size = 5, int repeat = 1)
        {
            var payload = GetCharPayload(size);
            var sender  = await SocketEvents.CreateConnection("127.0.0.1", 5050);

            for (int i = 0; i < repeat; i++)
            {
                sender.Publish(payload);
            }

            sender.Dispose();
        }
Beispiel #2
0
        private async Task ConnectAndSubscribeAsync(CountdownEvent pending)
        {
            var connection = await SocketEvents.CreateConnection(_args.Server, _args.Port);

            _monitor.OnConnect();
            var encodedConnection = connection.ToLengthPrefixed();

            lock (_clients)
            {
                _clients.Add(encodedConnection);
            }
            pending.Signal();
            encodedConnection.Subscribe(this.HandleResponse);
        }
Beispiel #3
0
        public async static Task SendData(int size = 5, int repeat = 1)
        {
            byte[] preamble = BitConverter.GetBytes(size);
            var    data     = Encoding.ASCII.GetBytes(GetChars(size));

            Contract.Assert(preamble.Length == 4);

            var buffer = new byte[size + preamble.Length];

            Buffer.BlockCopy(preamble, 0, buffer, 0, preamble.Length);
            Buffer.BlockCopy(data, 0, buffer, preamble.Length, data.Length);
            var payload = new ArraySegment <byte>(buffer);
            var sender  = await SocketEvents.CreateConnection("localhost", 5050);

            for (int i = 0; i < repeat; i++)
            {
                sender.Publish(payload);
            }

            sender.Dispose();
        }