Example #1
0
        private void AddPlayerToGame(String name, Guid newClientId)
        {
            this.playerListing.AddPlayer(name, newClientId);

            NetworkObjects.JoinGameResponse mJoinResponse = new NetworkObjects.JoinGameResponse();
            mJoinResponse.Success = true;
            server.Send(mJoinResponse, newClientId);

            // Send new player the full player listing
            server.Send(this.playerListing, newClientId);

            // Send new player to all other players
            foreach(NetworkObjects.PlayerListing.Player player in this.playerListing.Players)
            {
                // Don't send message to new client
                if (player.clientId == newClientId)
                    continue;

                NetworkObjects.PlayerJoined newPlayerMsg = new NetworkObjects.PlayerJoined();
                newPlayerMsg.Name = name;

                server.Send(newPlayerMsg, player.clientId);
            }

            Console.WriteLine(name + " has joined the game.");
        }
Example #2
0
        private void SendPlayerJoinFailedMessage(Guid clientId, String reason)
        {
            NetworkObjects.JoinGameResponse response = new NetworkObjects.JoinGameResponse();
            response.Success = false;
            response.ResponseMessage = reason;

            server.Send(response, clientId);
        }