Exemple #1
0
        private void HandleIncomingMessage(GameMessage msg, NetIncomingMessage original)
        {
            if (msg == null)
            {
                return;
            }

            switch (msg.GetMessageType())
            {
            case GameMessageType.PlayerControls:
                PlayerControlUpdateMessage controls = msg as PlayerControlUpdateMessage;
                _room.UpdatePlayerInput(original.SenderConnection.RemoteUniqueIdentifier, controls.Controls);
                break;

            default:
                Console.WriteLine("Unhandled Data Type " + msg.GetMessageType().ToString());
                break;
            }
        }
    private void HandleIncomingMessage(GameMessage msg)
    {
        switch (msg.GetMessageType())
        {
        case GameMessageType.PlayerConnected:
            Debug.Log("Player Connected " + (msg as PlayerConnectedMessage).PlayerID);
            break;

        case GameMessageType.PlayerDisconnected:
            Debug.Log("Player Disconnected " + (msg as PlayerDisconnectedMessage).PlayerID);
            break;
        }
    }
Exemple #3
0
 private void Broadcast(GameMessage message, NetDeliveryMethod method)
 {
     foreach (KeyValuePair <long, Player> entry in _players)
     {
         entry.Value.Connection.SendMessage(Server.MessageHandler.Encode(message), method, (int)message.GetMessageType());
     }
 }