Exemplo n.º 1
0
        // --------------- Join game handlers -----------------
        // queue
        private void OnServerJoinSoloQueueRequest(NetworkMessage netMsg)
        {
            ClientJoinSoloQueueRequestMessage msg = netMsg.ReadMessage <ClientJoinSoloQueueRequestMessage>();

            Debug.Log("Server received JoinSoloQueue request from " + msg.userId + " " + msg.userName);
            User u = usersByName[msg.userName];

            if (u.isIdentified)
            {
                if (soloQueue.queueUser(u))
                {
                    GameLogicServer newgame = soloQueue.checkQueue();
                    if (newgame != null)
                    {
                        games[newgame.gameId] = newgame;
                        ServerSendNewGameDataToPlayers(newgame);
                    }
                    else
                    {
                        ServerJoinSoloQueueResponseMessage responseMsg = new ServerJoinSoloQueueResponseMessage();
                        responseMsg.joinedQueue = true;
                        netMsg.conn.Send(ServerJoinSoloQueueResponseMessage.ID, responseMsg);
                    }
                }
            }
            else
            {
                ServerJoinSoloQueueResponseMessage responseMsg = new ServerJoinSoloQueueResponseMessage();
                responseMsg.joinedQueue = false;
                netMsg.conn.Send(ServerJoinSoloQueueResponseMessage.ID, responseMsg);
            }
        }
Exemplo n.º 2
0
        // --------------- Join game handlers -----------------

        // queue
        private void ClientJoinSoloQueueRequest()
        {
            ClientJoinSoloQueueRequestMessage msg = new ClientJoinSoloQueueRequestMessage();

            msg.userId   = user.userId;
            msg.userName = user.userName;
            client.Send(ClientJoinSoloQueueRequestMessage.ID, msg);
            user.isQueued = true;
            Debug.Log("Sent join solo queue request");
        }