예제 #1
0
        public async Task Run(JsonSocket socket, CancellationToken ct)
        {
            for (var i = 0; i < 10; i++)
            {
                await socket.SendBinaryBson(new { counter = i });

                await Task.Delay(500);
            }
        }
예제 #2
0
        public void ClientConnected(JsonSocket socket)
        {
            Console.WriteLine("[{0}] Connected.", socket.RemoteEndPoint);

            socket.OnReceivedBinaryBson += async(data) =>
            {
                Console.WriteLine("[{0}] Received binary Bson: {1}", socket.RemoteEndPoint, data);
                await socket.SendBinaryBson(data);
            };
        }
예제 #3
0
        static async Task StartSending(JsonSocket socket)
        {
            while (socket.Connected)
            {
                dynamic data = new { name = "Sample", time = DateTime.Now };
                await socket.SendBinaryBson(data);

                await Task.Delay(1000);
            }
        }