public virtual void DisplayMessage(BaseClient client, string message)
 {
     if (client != null)
     {
         client.DisplayMessage(message);
     }
 }
Пример #2
0
 public static void DisplaySyntax(BaseClient client)
 {
     client.DisplayMessage("Commands list:");
     foreach (string str in GetCommandList(ePrivLevel.Admin, true))
     {
         client.DisplayMessage("         "+str);
     }
 }
Пример #3
0
 public BaseClient[] GetAllClients()
 {
     lock (_clients.SyncRoot)
     {
         BaseClient[] temp = new BaseClient[_clients.Count];
         _clients.Keys.CopyTo(temp,0);
         return temp;
     }
 }
Пример #4
0
        public bool OnCommand(BaseClient client, string[] args)
        {
            foreach (string str in args)
            {
                DisplayMessage(client, str);
            }

            return true;
        }
 public virtual void DisplaySyntax(BaseClient client)
 {
     if (client != null)
     {
         CmdAttribute[] attrib = (CmdAttribute[])this.GetType().GetCustomAttributes(typeof(CmdAttribute), false);
         if (attrib.Length > 0)
         {
             client.DisplayMessage(attrib[0].Description);
             foreach (string str in attrib[0].Usage)
                 client.DisplayMessage(str);
         }
     }
 }
Пример #6
0
        /// <summary>
        /// Constructs a new PacketProcessor
        /// </summary>
        /// <param name="client">The processor client</param>
        public StreamProcessor(BaseClient client)
        {
            m_client = client;
            m_client.resetKey();

            m_tcpSendBuffer = client.SendBuffer;
            m_tcpQueue = new Queue(256);

            send_event = new SocketAsyncEventArgs();
            send_event.UserToken = this;
            send_event.Completed += new EventHandler<SocketAsyncEventArgs>(StreamProcessor.AsyncTcpSendCallback); //AsyncTcpSendCallback;
            send_event.SetBuffer(m_tcpSendBuffer, 0, 0);

            send_fsm = new FSM(0x7abcdef7, 1501,"send_fsm");
            receive_fsm = new FSM(0x7abcdef7, 1501,"receive_fsm");
        }
Пример #7
0
        public bool OnCommand(BaseClient client, string[] args)
        {
            if (args.Length >= 4)
            {
                string path = args[1];
                string target = args[2];
                string libs = args[3];
                ScriptMgr.CompileScripts(false, path, target,libs.Split(','));
            }
            else
            {
                DisplaySyntax(client);
            }

            return true;
        }
 public virtual void DisplayMessage(BaseClient client, string format, params object[] args)
 {
     DisplayMessage(client, string.Format(format, args));
 }
Пример #9
0
 private static bool ExecuteCommand(BaseClient client, GameCommand myCommand, string[] pars)
 {
     pars[0] = myCommand.m_cmd;
     return myCommand.m_cmdHandler.OnCommand(client, pars);
 }
Пример #10
0
 /// <summary>
 /// Remove a client from collection.
 /// </summary>
 /// <param name="client"></param>
 public virtual void RemoveClient(BaseClient client)
 {
     lock (_clients.SyncRoot)
     {
         _clients.Remove(client);
     }
 }
Пример #11
0
        public static bool HandleCommandNoPlvl(BaseClient client, string cmdLine)
        {
            try
            {
                string[] pars = ParseCmdLine(cmdLine);
                GameCommand myCommand = GuessCommand(pars[0]);

                if (myCommand == null) return false;

                ExecuteCommand(client, myCommand, pars);
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("HandleCommandNoPlvl", e);
            }
            return true;
        }
Пример #12
0
 private static bool ExecuteCommand(BaseClient client, GameCommand myCommand, string[] pars)
 {
     pars[0] = myCommand.m_cmd;
     return(myCommand.m_cmdHandler.OnCommand(client, pars));
 }
Пример #13
0
        /// <summary>
        /// Stops the server
        /// </summary>
        public virtual void Stop()
        {
            log.Debug("Stopping server! - Entering method");
            try
            {
                if (_linstener != null)
                {
                    Socket socket = _linstener;
                    _linstener = null;
                    socket.Close();
                    log.Debug("Server is no longer listening for incoming connections!");
                }
            }
            catch (Exception e)
            {
                log.Error("Stop", e);
            }

            if (_clients != null)
            {
                lock (_clients.SyncRoot)
                {
                    try
                    {
                        BaseClient[] list = new BaseClient[_clients.Keys.Count];
                        _clients.Keys.CopyTo(list, 0);

                        foreach (BaseClient client in list)
                        {
                            client.Disconnect();
                        }

                        log.Debug("Stopping server! - Cleaning up client list!");
                    }
                    catch (Exception e)
                    {
                        log.Error("Stop", e);
                    }
                }
            }
            log.Debug("Stopping server! - End of method!");
        }
Пример #14
0
 void m_fightingServer_Disconnected(BaseClient client)
 {
     Stop();
 }
Пример #15
0
 private void loginServer_Disconnected(BaseClient client)
 {
     bool running = m_isRunning;
     Stop();
     if (running && m_tryCount > 0)
     {
         m_tryCount--;
         log.Error("Center Server Disconnect! Stopping Server");
         log.ErrorFormat("Start the game server again after 1 second,and left try times:{0}", m_tryCount);
         Thread.Sleep(1000);
         if (Start())
         {
             log.Error("Restart the game server success!");
         }
     }
     else
     {
         if (m_tryCount == 0)
         {
             log.ErrorFormat("Restart the game server failed after {0} times.", 4);
             log.Error("Server Stopped!");
         }
         LogManager.Shutdown();
     }
 }
Пример #16
0
 public virtual void DisplayMessage(BaseClient client, string format, params object[] args)
 {
     this.DisplayMessage(client, string.Format(format, args));
 }
Пример #17
0
 public bool OnCommand(BaseClient client, string[] args)
 {
     if (args.Length > 1)
     {
         switch (args[1])
         {
             case "-c":
                 Console.WriteLine("client list:");
                 Console.WriteLine("-------------------------------");
                 GameClient[] cs = GameServer.Instance.GetAllClients();
                 foreach (GameClient cl in cs)
                 {
                     Console.WriteLine(cl.ToString());
                 }
                 Console.WriteLine("-------------------------------");
                 Console.WriteLine(string.Format("total:{0}", cs.Length));
                 break;
             case "-p":
                 Console.WriteLine("player list:");
                 Console.WriteLine("-------------------------------");
                 GamePlayer[] ps = WorldMgr.GetAllPlayers();
                 foreach (GamePlayer player in ps)
                 {
                     Console.WriteLine(player.ToString());
                 }
                 Console.WriteLine("-------------------------------");
                 Console.WriteLine(string.Format("total:{0}", ps.Length));
                 break;
             case "-r":
                 Console.WriteLine("room list:");
                 Console.WriteLine("-------------------------------");
                 List<BaseRoom> rs = RoomMgr.GetAllUsingRoom();
                 foreach (BaseRoom room in rs)
                 {
                     Console.WriteLine(room.ToString());
                 }
                 Console.WriteLine("-------------------------------");
                 Console.WriteLine(string.Format("total:{0}", rs.Count));
                 break;
             case "-g":
                 Console.WriteLine("game list:");
                 Console.WriteLine("-------------------------------");
                 List<BaseGame> gs = GameMgr.GetAllGame();
                 foreach (BaseGame g in gs)
                 {
                     Console.WriteLine(g.ToString());
                 }
                 Console.WriteLine("-------------------------------");
                 Console.WriteLine(string.Format("total:{0}", gs.Count));
                 break;
             case "-b":
                 Console.WriteLine("battle list:");
                 Console.WriteLine("-------------------------------");
                 List<BattleServer> bs = BattleMgr.GetAllBattles();
                 foreach (BattleServer battleSvr in bs)
                 {
                     Console.WriteLine(battleSvr.ToString());
                 }
                 Console.WriteLine("-------------------------------");
                 Console.WriteLine(string.Format("total:{0}", bs.Count));
                 break;
             default:
                 DisplaySyntax(client);
                 break;
         }
     }
     else
     {
         DisplaySyntax(client);
     }
     return true;
 }
Пример #18
0
        public bool OnCommand(BaseClient client, string[] args)
        {
            //TODO,完成gp命令的内容

            return true;
        }
Пример #19
0
        public bool OnCommand(BaseClient client, string[] args)
        {
            DisplayMessage(client,"Servion Id:{0},Version:{1}",GameServer.Instance.Configuration.ServerID,GameServer.Edition);

            return true;
        }
Пример #20
0
 private void client_Disconnected(BaseClient client)
 {
     client.Disconnected -= client_Disconnected;
     RemoveClient(client);
 }
Пример #21
0
        public bool OnCommand(BaseClient client, string[] args)
        {
            if (args.Length > 1)
            {
                StringBuilder success = new StringBuilder();
                StringBuilder failed = new StringBuilder();
                if (args.Contains<string>("/cmd"))
                {
                    CommandMgr.LoadCommands();
                    DisplayMessage(client, "Command load success!");
                    success.Append("/cmd,");
                }

                if (args.Contains<string>("/config"))
                {
                    GameServer.Instance.Configuration.Refresh();
                    DisplayMessage(client, "Application config file load success!");
                    success.Append("/config,");
                }

                if (args.Contains<string>("/property"))
                {
                    GameProperties.Refresh();
                    DisplayMessage(client, "Game properties load success!");
                    success.Append("/property,");
                }

                if (args.Contains<string>("/item"))
                {
                    if (ItemMgr.ReLoad())
                    {
                        DisplayMessage(client,"Items load success!");
                        success.Append("/item,");
                    }
                    else
                    {
                        DisplayMessage(client,"Items load failed!");
                        failed.Append("/item,");
                    }
                }
                if (args.Contains<string>("/shop"))
                {
                    if (ItemMgr.ReLoad())
                    {
                        DisplayMessage(client, "Shops load success!");
                        success.Append("/shop,");
                    }
                    else
                    {
                        DisplayMessage(client,"Shops load failed!");
                        failed.Append("/shop,");
                    }
                }
                if (success.Length == 0 && failed.Length == 0)
                {
                    DisplayMessage(client,"Nothing executed!");
                    DisplaySyntax(client);
                }
                else
                {
                    DisplayMessage(client,"Success Options:    " + success.ToString());

                    if (failed.Length > 0)
                    {
                        DisplayMessage(client, "Faile Options:      " + failed.ToString());
                        return false;
                    }
                }
                return true;
            }
            else
            {
                DisplaySyntax(client);
            }
            return true;
        }
Пример #22
0
 private void client_Disconnected(BaseClient client)
 {
     client.Disconnected -= new ClientEventHandle(this.client_Disconnected);
     this.RemoveClient(client);
 }