Exemplo n.º 1
0
 void netMgr_MessageArrived(object sender, IncomingNetworkMessageArgs e)
 {
     //Make sure we reset the position - we might recieve this message after the gamestates.
     if (e.Message.Position > 0) e.Message.Position = 0;
     if (e.Message.MessageType == NetIncomingMessageType.Data && (NetMessage)e.Message.PeekByte() == NetMessage.ConsoleCommandReply)
     {
         e.Message.ReadByte();
         AddLine("Server: " + e.Message.ReadString(), Color.RoyalBlue);
     }
     //Again, make sure we reset the position - we might get it before the gamestate and then that would break.
     e.Message.Position = 0;
 }
Exemplo n.º 2
0
 private void NetworkManagerMessageArrived(object sender, IncomingNetworkMessageArgs args)
 {
     NetIncomingMessage message = args.Message;
     switch (message.MessageType)
     {
         case NetIncomingMessageType.StatusChanged:
             var statMsg = (NetConnectionStatus) message.ReadByte();
             if (statMsg == NetConnectionStatus.Disconnected)
             {
                 string disconnectMessage = message.ReadString();
                 UserInterfaceManager.AddComponent(new DisconnectedScreenBlocker(StateManager,
                                                                                 UserInterfaceManager,
                                                                                 ResourceManager,
                                                                                 disconnectMessage));
             }
             break;
         case NetIncomingMessageType.Data:
             var messageType = (NetMessage) message.ReadByte();
             switch (messageType)
             {
                 case NetMessage.LobbyChat:
                     string text = message.ReadString();
                     AddChat(text);
                     break;
                 case NetMessage.PlayerCount:
                     //TODO var newCount = message.ReadByte();
                     break;
                 case NetMessage.PlayerList:
                     HandlePlayerList(message);
                     break;
                 case NetMessage.WelcomeMessage:
                     HandleWelcomeMessage(message);
                     break;
                 case NetMessage.ChatMessage:
                     HandleChatMessage(message);
                     break;
                 case NetMessage.JobList:
                     HandleJobList(message);
                     break;
                 case NetMessage.JobSelected:
                     HandleJobSelected(message);
                     break;
                 case NetMessage.JoinGame:
                     HandleJoinGame();
                     break;
             }
             break;
     }
 }
Exemplo n.º 3
0
 private void NetworkManagerMessageArrived(object sender, IncomingNetworkMessageArgs args)
 {
     NetIncomingMessage message = args.Message;
     if (message == null)
     {
         return;
     }
     switch (message.MessageType)
     {
         case NetIncomingMessageType.StatusChanged:
             var statMsg = (NetConnectionStatus)message.ReadByte();
             if (statMsg == NetConnectionStatus.Disconnected)
             {
                 string disconnectMessage = message.ReadString();
                 UserInterfaceManager.AddComponent(new DisconnectedScreenBlocker(StateManager,
                                                                                 UserInterfaceManager,
                                                                                 ResourceManager,
                                                                                 disconnectMessage));
             }
             break;
         case NetIncomingMessageType.Data:
             var messageType = (NetMessage)message.ReadByte();
             switch (messageType)
             {
                 case NetMessage.MapMessage:
                     MapManager.HandleNetworkMessage(message);
                     break;
                 //case NetMessage.AtmosDisplayUpdate:
                 //    MapManager.HandleAtmosDisplayUpdate(message);
                 //    break;
                 case NetMessage.PlayerSessionMessage:
                     PlayerManager.HandleNetworkMessage(message);
                     break;
                 case NetMessage.PlayerUiMessage:
                     UserInterfaceManager.HandleNetMessage(message);
                     break;
                 case NetMessage.PlacementManagerMessage:
                     PlacementManager.HandleNetMessage(message);
                     break;
                 case NetMessage.ChatMessage:
                     HandleChatMessage(message);
                     break;
                 case NetMessage.EntityMessage:
                     _entityManager.HandleEntityNetworkMessage(message);
                     break;
                 case NetMessage.RequestAdminLogin:
                     HandleAdminMessage(messageType, message);
                     break;
                 case NetMessage.RequestAdminPlayerlist:
                     HandleAdminMessage(messageType, message);
                     break;
                 case NetMessage.RequestBanList:
                     HandleAdminMessage(messageType, message);
                     break;
                 case NetMessage.StateUpdate:
                     HandleStateUpdate(message);
                     break;
                 case NetMessage.FullState:
                     HandleFullState(message);
                     break;
             }
             break;
     }
 }