//William Dewing 12/12/16
    //Updates the player count of a room on the maseter server

    void OnServerUpdateHost(NetworkMessage netMsg)
    {
        Debug.Log("OnServerUpdateHost");
        var msg = netMsg.ReadMessage <MasterMsgTypes.UpdateHostMessage>();

        // find the room
        var rooms = EnsureRoomsForGameType(msg.gameTypeName);

        if (!rooms.rooms.ContainsKey(msg.gameName))
        {
            //error
            Debug.Log("OnServerUpdateHost game not found: " + msg.gameName);
            return;
        }

        var room = rooms.rooms[msg.gameName];

        if (room.connectionId != netMsg.conn.connectionId)
        {
            //err
            Debug.Log("OnServerUpdateHost connection mismatch:" + room.connectionId);
            return;
        }

        room.players = msg.players; //Update Player Count of Host

        var response = new MasterMsgTypes.RegisteredHostMessage();

        response.resultCode = (int)MasterMsgTypes.NetworkMasterServerEvent.UpdateSucceeded;
        netMsg.conn.Send(MasterMsgTypes.UpdatedHostId, response);
    }
    // --------------- Application Handlers -----------------

    void OnServerRegisterHost(NetworkMessage netMsg)
    {
        Debug.Log("OnServerRegisterHost");
        var msg   = netMsg.ReadMessage <MasterMsgTypes.RegisterHostMessage>();
        var rooms = EnsureRoomsForGameType(msg.gameTypeName);

        int result = (int)MasterMsgTypes.NetworkMasterServerEvent.RegistrationSucceeded;

        if (!rooms.AddHost(msg.gameName, msg.comment, msg.players, msg.playerLimit, netMsg.conn.address, msg.hostPort, netMsg.conn.connectionId))
        {
            result = (int)MasterMsgTypes.NetworkMasterServerEvent.RegistrationFailedGameName;
        }

        var response = new MasterMsgTypes.RegisteredHostMessage();

        response.resultCode = result;
        netMsg.conn.Send(MasterMsgTypes.RegisteredHostId, response);
    }