Ejemplo n.º 1
0
 private void HandleReceive(string value)
 {
     var message = ParseMessage(value);
     switch (message["type"])
     {
         case "prepare-new-game":
             gameHandler = GetHandler(message["game"]);
             gameHandler.PrepareNewGame(message);
             connection.Send("ready");
             return;
         case "update-game-state":
             gameHandler.UpdateGameState(message);
             connection.Send("ready");
             break;
         case "make-move":
             var newState = gameHandler.MakeMove(message);
             connection.Send("move " + newState.LastMoveDescription());
             break;
         case "announce-results":
             // this will be logged automatically, clean up resources
             gameHandler = null;
             break;
         default:
             throw new Exception("Unknown message type received.");
     }
 }