/// <summary>
 /// Initializes a new instance of the <see cref="Client"/> class. 
 /// The client.
 /// </summary>
 /// <param name="srvr">
 /// </param>
 public Client(ChatServer srvr)
     : base(srvr)
 {
     this.Character = new Character(0, null);
     this.ServerSalt = string.Empty;
     this.knownClients = new Collection<uint>();
 }
        /// <summary>
        /// Link this client to the server Engine
        /// </summary>
        /// <param name="ip">
        /// The ip.
        /// </param>
        /// <param name="port">
        /// The port.
        /// </param>
        /// <param name="srv">
        /// The srv.
        /// </param>
        /// <returns>
        /// The link.
        /// </returns>
        public static bool Link(string ip, int port, ChatServer srv)
        {
            try
            {
                Client = new IscClient(ip, port, srv);
            }
            catch (Exception e)
            {
                Console.WriteLine("[ISComm] Failure: " + e);
                return false;
            }

            return true;
        }
Esempio n. 3
0
        /// <summary>
        /// </summary>
        /// <returns>
        /// </returns>
        private static bool Initialize()
        {
            try
            {
                chatServer = new ChatServer();

                if (!InitializeLogAndBug())
                {
                    return(false);
                }

                if (!InitializeTCP())
                {
                    return(false);
                }

                if (!InitializeISCom())
                {
                    return(false);
                }

                if (!InitializeConsoleCommands())
                {
                    return(false);
                }

                PlayfieldLoader.CacheAllPlayfieldData();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.ReadLine();
                return(false);
            }

            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// </summary>
        /// <returns>
        /// </returns>
        private static bool Initialize()
        {
            try
            {
                chatServer = new ChatServer();

                if (!InitializeLogAndBug())
                {
                    return false;
                }

                if (!InitializeTCP())
                {
                    return false;
                }

                if (!InitializeISCom())
                {
                    return false;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.ReadLine();
                return false;
            }

            return true;
        }
Esempio n. 5
0
        /// <summary>
        /// The main.
        /// </summary>
        /// <param name="args">
        /// Program arguments
        /// </param>
        private static void Main(string[] args)
        {
            Console.Title = "CellAO " + AssemblyInfoclass.Title + " Console. Version: " + AssemblyInfoclass.Description
                            + " " + AssemblyInfoclass.AssemblyVersion + " " + AssemblyInfoclass.Trademark;

            ConsoleText ct = new ConsoleText();

            ct.TextRead("main.txt");
            Console.WriteLine("Loading " + AssemblyInfoclass.Title + "...");

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Using ISComm v1.0");
            Console.WriteLine("[OK]");
            Console.ResetColor();

            bool       processedArgs = false;
            ChatServer chatServer    = new ChatServer();

            Console.WriteLine("[ISComm] Waiting for link...");

            #region NLog
            LoggingConfiguration config        = new LoggingConfiguration();
            ColoredConsoleTarget consoleTarget = new ColoredConsoleTarget();
            consoleTarget.Layout = "${date:format=HH\\:MM\\:ss} ${logger} ${message}";
            FileTarget fileTarget = new FileTarget();
            config.AddTarget("file", fileTarget);
            fileTarget.FileName = "${basedir}/ChatEngineLog.txt";
            fileTarget.Layout   = "${date:format=HH\\:MM\\:ss} ${logger} ${message}";
            LoggingRule rule1 = new LoggingRule("*", LogLevel.Trace, consoleTarget);
            config.LoggingRules.Add(rule1);
            LoggingRule rule2 = new LoggingRule("*", LogLevel.Trace, fileTarget);
            config.LoggingRules.Add(rule2);
            LogManager.Configuration = config;
            #endregion

            #region NBug

            SettingsOverride.LoadCustomSettings("NBug.ChatEngine.Config");
            Settings.WriteLogToDisk = true;
            AppDomain.CurrentDomain.UnhandledException += Handler.UnhandledException;
            TaskScheduler.UnobservedTaskException      += Handler.UnobservedTaskException;

            // TODO: ADD More Handlers.
            #endregion

            IPAddress localISComm;

            try
            {
                // Local ISComm IP valid?
                localISComm = IPAddress.Parse(Config.Instance.CurrentConfig.ISCommLocalIP);
            }
            catch
            {
                // Fallback to ZoneIP
                localISComm = IPAddress.Parse(Config.Instance.CurrentConfig.ZoneIP);
            }

            if (!ZoneCom.Link(localISComm.ToString(), Config.Instance.CurrentConfig.CommPort, chatServer))
            {
                Console.WriteLine("[ISComm] Unable to link to ZoneEngine. :(");
                return;
            }

            Console.WriteLine("[ISComm] Linked with ZoneEngine! :D");

            chatServer.EnableTCP = true;
            chatServer.EnableUDP = false;

            try
            {
                chatServer.TcpIP = IPAddress.Parse(Config.Instance.CurrentConfig.ListenIP);
            }
            catch
            {
                ct.TextRead("ip_config_parse_error.txt");
                Console.ReadKey();
                return;
            }

            try
            {
                chatServer.UdpIP = IPAddress.Parse(Config.Instance.CurrentConfig.ListenIP);
            }
            catch
            {
                ct.TextRead("ip_config_parse_error.txt");
                Console.ReadKey();
                return;
            }

            chatServer.TcpPort = Convert.ToInt32(Config.Instance.CurrentConfig.ChatPort);
            chatServer.MaximumPendingConnections = 100;

            AppDomain.CurrentDomain.UnhandledException += Handler.UnhandledException;
            TaskScheduler.UnobservedTaskException      += Handler.UnobservedTaskException;

            // TODO: ADD More Handlers.

            // Andyzweb: I added checks for if the server is running or not
            // also a command called running that returns the status of the server
            // and added the Console.Write("\nServer Command >>"); to chatserver
            string consoleCommand;
            ct.TextRead("chat_consolecommands.txt");
            while (true)
            {
                if (!processedArgs)
                {
                    if (args.Length == 1)
                    {
                        if (args[0].ToLower() == "/autostart")
                        {
                            ct.TextRead("autostart.txt");
                            ThreadMgr.Start();
                            chatServer.Start();
                        }
                    }

                    processedArgs = true;
                }

                Console.Write("\nServer Command >>");
                consoleCommand = Console.ReadLine();
                switch (consoleCommand.ToLower())
                {
                case "start":
                    if (chatServer.Running)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Chat Server is already running");
                        Console.ResetColor();
                        break;
                    }

                    ThreadMgr.Start();
                    chatServer.Start();
                    break;

                case "stop":
                    if (!chatServer.Running)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Chat Server is not running");
                        Console.ResetColor();
                        break;
                    }

                    ThreadMgr.Stop();
                    chatServer.Stop();
                    break;

                case "exit":
                    Process.GetCurrentProcess().Kill();
                    break;

                case "running":
                    if (chatServer.Running)
                    {
                        Console.WriteLine("Chat Server is Running");
                        break;
                    }

                    Console.WriteLine("Chat Server not Running");
                    break;

                default:
                    ct.TextRead("chat_consolecmdsdefault.txt");
                    break;
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// </summary>
        /// <param name="chatServer">
        /// </param>
        public void Run(ChatServer chatServer)
        {
            this.Run();
            if (Config.Instance.CurrentConfig.UseIRCRelay)
            {
                // Find ingame channel to relay
                string temp = Config.Instance.CurrentConfig.RelayIngameChannel;
                this.RelayedChannel = chatServer.Channels.FirstOrDefault(x => x.ChannelName == temp);
                if (this.RelayedChannel == null)
                {
                    LogUtil.Debug(DebugInfoDetail.Engine, "Could not find ChatEngine Channel '" + temp + "'");
                    return;
                }

                this.RelayedChannel.OnChannelMessage += this.RelayedChannel_OnChannelMessage;

                // Found ingame channel, now connect to IRC
                this.Connect(Config.Instance.CurrentConfig.IRCServer, this.RegistrationInfo);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// The main.
        /// </summary>
        /// <param name="args">
        /// Program arguments
        /// </param>
        private static void Main(string[] args)
        {
            Console.Title = "CellAO " + AssemblyInfoclass.Title + " Console. Version: " + AssemblyInfoclass.Description
                            + " " + AssemblyInfoclass.AssemblyVersion;
            ConsoleText ct = new ConsoleText();
            ct.TextRead("main.txt");
            Console.WriteLine("Loading " + AssemblyInfoclass.Title + "...");
            if (IsModified())
            {
                Console.WriteLine("Your " + AssemblyInfoclass.Title + " was compiled from modified source code.");
            }
            else if (IsMixed())
            {
                Console.WriteLine("Your " + AssemblyInfoclass.Title + " uses mixed SVN revisions.");
            }

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Using ISComm v1.0");
            Console.WriteLine("[OK]");
            Console.ResetColor();

            bool processedArgs = false;
            ChatServer chatServer = new ChatServer();

            Console.WriteLine("[ISComm] Waiting for link...");

            LoggingConfiguration config = new LoggingConfiguration();
            ColoredConsoleTarget consoleTarget = new ColoredConsoleTarget();
            consoleTarget.Layout = "${date:format=HH\\:MM\\:ss} ${logger} ${message}";
            FileTarget fileTarget = new FileTarget();
            config.AddTarget("file", fileTarget);
            fileTarget.FileName = "${basedir}/ChatEngineLog.txt";
            fileTarget.Layout = "${date:format=HH\\:MM\\:ss} ${logger} ${message}";
            LoggingRule rule1 = new LoggingRule("*", LogLevel.Trace, consoleTarget);
            config.LoggingRules.Add(rule1);
            LoggingRule rule2 = new LoggingRule("*", LogLevel.Trace, fileTarget);
            config.LoggingRules.Add(rule2);
            LogManager.Configuration = config;

            IPAddress localISComm;

            try
            {
                // Local ISComm IP valid?
                localISComm = IPAddress.Parse(Config.Instance.CurrentConfig.ISCommLocalIP);
            }
            catch
            {
                // Fallback to ZoneIP
                localISComm = IPAddress.Parse(Config.Instance.CurrentConfig.ZoneIP);
            }

            if (!ZoneCom.Link(localISComm.ToString(), Config.Instance.CurrentConfig.CommPort, chatServer))
            {
                Console.WriteLine("[ISComm] Unable to link to ZoneEngine. :(");
                return;
            }

            Console.WriteLine("[ISComm] Linked with ZoneEngine! :D");

            chatServer.EnableTCP = true;
            chatServer.EnableUDP = false;

            try
            {
                chatServer.TcpIP = IPAddress.Parse(Config.Instance.CurrentConfig.ListenIP);
            }
            catch
            {
                ct.TextRead("ip_config_parse_error.txt");
                Console.ReadKey();
                return;
            }

            try
            {
                chatServer.UdpIP = IPAddress.Parse(Config.Instance.CurrentConfig.ListenIP);
            }
            catch
            {
                ct.TextRead("ip_config_parse_error.txt");
                Console.ReadKey();
                return;
            }

            chatServer.TcpPort = Convert.ToInt32(Config.Instance.CurrentConfig.ChatPort);
            chatServer.MaximumPendingConnections = 100;

            #region NBug
            AppDomain.CurrentDomain.UnhandledException += Handler.UnhandledException;
            TaskScheduler.UnobservedTaskException += Handler.UnobservedTaskException;

            // TODO: ADD More Handlers.
            #endregion

            #region Console Commands
            // Andyzweb: I added checks for if the server is running or not
            // also a command called running that returns the status of the server
            // and added the Console.Write("\nServer Command >>"); to chatserver
            string consoleCommand;
            ct.TextRead("chat_consolecommands.txt");
            while (true)
            {
                if (!processedArgs)
                {
                    if (args.Length == 1)
                    {
                        if (args[0].ToLower() == "/autostart")
                        {
                            ct.TextRead("autostart.txt");
                            ThreadMgr.Start();
                            chatServer.Start();
                        }
                    }

                    processedArgs = true;
                }

                Console.Write("\nServer Command >>");
                consoleCommand = Console.ReadLine();
                switch (consoleCommand.ToLower())
                {
                    case "start":
                        if (chatServer.Running)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("Chat Server is already running");
                            Console.ResetColor();
                            break;
                        }

                        ThreadMgr.Start();
                        chatServer.Start();
                        break;
                    case "stop":
                        if (!chatServer.Running)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("Chat Server is not running");
                            Console.ResetColor();
                            break;
                        }

                        ThreadMgr.Stop();
                        chatServer.Stop();
                        break;
                    case "exit":
                        Process.GetCurrentProcess().Kill();
                        break;
                    case "running":
                        if (chatServer.Running)
                        {
                            Console.WriteLine("Chat Server is Running");
                            break;
                        }

                        Console.WriteLine("Chat Server not Running");
                        break;
                    default:
                        ct.TextRead("chat_consolecmdsdefault.txt");
                        break;
                }
            }
            #endregion
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="IscClient"/> class.
        /// </summary>
        /// <param name="ip">
        /// The ip.
        /// </param>
        /// <param name="port">
        /// The port.
        /// </param>
        /// <param name="srv">
        /// The srv.
        /// </param>
        public IscClient(string ip, int port, ChatServer srv)
            : base(ip, port)
        {
            this.OnMessage += this.ISCClient_OnMessage;

            this.server = srv;
        }
Esempio n. 9
0
        /// <summary>
        /// </summary>
        /// <returns>
        /// </returns>
        private static bool Initialize()
        {
            try
            {
                chatServer = new ChatServer();

                if (!InitializeLogAndBug())
                {
                    return false;
                }

                if (!InitializeTCP())
                {
                    return false;
                }

                if (!InitializeISCom())
                {
                    return false;
                }

                if (!InitializeConsoleCommands())
                {
                    return false;
                }

                PlayfieldLoader.CacheAllPlayfieldData();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.ReadLine();
                return false;
            }

            return true;
        }