Пример #1
0
 public void BroadcastMessage(C.Chat p)
 {
     SMain.EnqueueDebugging(string.Format("{0}.", p.Message));
     SMain.Envir.Broadcast(new S.Chat {
         Message = p.Message.Replace("!", "(!)"), Type = ChatType.Announcement
     });
 }
Пример #2
0
 public void ReceiveCommand(C.Chat p)
 {
     if (!LoggedIn)
     {
         return;
     }
     SMain.EnqueueDebugging(string.Format("Command Received : {0}", p.Message));
     if (SMain.Envir.ManagerCommands != null)
     {
         SMain.Envir.ManagerCommands.Add(p.Message);
     }
 }
Пример #3
0
        private void Chat(C.Chat p)
        {
            if (p.Message.Length > Globals.MaxChatLength)
            {
                SendDisconnect(2);
                return;
            }

            if (Stage != GameStage.Game)
            {
                return;
            }

            Player.Chat(p.Message);
        }
Пример #4
0
        public void MessageToPlayer(C.Chat p)
        {
            string playerName = "";

            playerName = p.Message.Replace("/", "");
            string[] split = playerName.Split(' ');
            if (split.Length <= 1)
            {
                return;
            }
            playerName = split[0];
            string message = "SYSTEM";

            for (int i = 1; i < split.Length; i++)
            {
                message += string.Format(" {0}", split[i]);
            }
            PlayerObject player = SMain.Envir.GetPlayer(playerName);

            if (player == null)
            {
                Enqueue(new S.Chat {
                    Message = string.Format("{0} could not be found", playerName), Type = ChatType.System
                });
                Enqueue(new S.Chat {
                    Message = string.Format("{0} could not be found", playerName), Type = ChatType.WhisperOut
                });
                if (Settings.DebugServerManager)
                {
                    SMain.EnqueueDebugging(string.Format("{0} could not be found.", playerName));
                }
                return;
            }
            if (player.Connection != null &&
                player.Connection.Connected &&
                player.Connection.Stage == GameStage.Game)
            {
                if (Settings.DebugServerManager)
                {
                    SMain.EnqueueDebugging(string.Format("Messenger > {0} : {1}", playerName, message));
                }
                player.ReceiveChat(message, ChatType.WhisperIn);
                Enqueue(new S.Chat {
                    Message = message, Type = ChatType.WhisperOut
                });
            }
        }
Пример #5
0
        private void ProcessPacket(Packet p)
        {
            if (DebugMode)
            {
                SMain.EnqueueDebugging(string.Format("Packet Received {0}", p.Index));
            }
            if (p == null || Disconnecting)
            {
                return;
            }
            switch (p.Index)
            {
            case (short)ClientPacketIds.ExternalToolLogin:
                if (DebugMode)
                {
                    SMain.EnqueueDebugging(string.Format("{0} logging in...", IPAddress));
                }
                CheckExternalLogin((C.ExternalToolLogin)p);
                break;

            case (short)ClientPacketIds.Disconnect:
                SMain.EnqueueDebugging(string.Format("{0} disconnected.", ManagerUser));
                Disconnect();
                break;

            case (short)ClientPacketIds.KeepAlive:
                C.KeepAlive keepAlive = (C.KeepAlive)p;
                if (DebugMode)
                {
                    SMain.EnqueueDebugging(string.Format("Keep Alive {0}", keepAlive.Time));
                }
                break;

            case (short)ClientPacketIds.ToolStats:
                if (LoggedIn)
                {
                    GetStats();
                }
                break;

            case (short)ClientPacketIds.Chat:
                if (LoggedIn)
                {
                    C.Chat   chat   = (C.Chat)p;
                    string[] splits = chat.Message.Split(' ');
                    if (splits.Length == 0)
                    {
                        Enqueue(new S.Chat {
                            Message = string.Format("Invalid Input"), Type = ChatType.System
                        });
                        break;
                    }
                    else
                    {
                        if (splits[0].StartsWith("@"))
                        {
                            ReceiveCommand((C.Chat)p);
                        }
                        else if (splits[0].StartsWith("/"))
                        {
                            if (SMain.Envir.Running)
                            {
                                MessageToPlayer((C.Chat)p);
                            }
                        }
                        else if (splits[0].StartsWith("!"))
                        {
                            if (SMain.Envir.Running)
                            {
                                BroadcastMessage((C.Chat)p);
                            }
                        }
                        break;
                    }
                }
                break;

            default:
                SMain.EnqueueDebugging(string.Format("Invalid Packet for Server Manager\nIndex : {0}", p.Index));
                break;
            }
        }