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); } }
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); }; }
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); } }