static async Task ReadWebsocket(Websocket ws, BufferBlock<GameTask> gameTasks, UserConnection uc, PlayerState player) { string next; while ((next = await ws.ReadFrame()) != null) { var update = JSON.Deserialize<PlayerCommand>(next); if (player.Dead) { //this is now checked in two places, but at least dead players won't send move commands to the main work channel continue; } dynamic command = ParseCommand(update); if (command == null) { continue; } var updatetask = new UpdateTask(command, player); await gameTasks.SendAsync(updatetask); } uc.Closed = true; await uc.SendAsync(null); }