public override void OnHandshakeInbound(Packet pPacket)
        {
            Logger.WriteLine("Received HandShake packet");
            Program.UpdateDate();

            short  version       = (short)MapleVersion;
            string patchLocation = MaplePatchLocation;
            byte   locale        = MapleLocale;

            if (oldPatchLocation == "XD" || (oldVersion == version && oldPatchLocation == patchLocation && oldLocale == locale))
            {
                TwitterClient.Instance.SendMessage("Connected with the {0} server. Version: V{1}.{2}", GetMapleStoryLocale(locale), version, patchLocation);
            }
            else
            {
                TwitterClient.Instance.SendMessage("Connected with the {0} server, and it seems to be updated! From V{1}.{2} to V{3}.{4} #MapleStory", GetMapleStoryLocale(locale), oldVersion, oldPatchLocation, version, patchLocation);
            }


            oldVersion       = version;
            oldPatchLocation = patchLocation;
            oldLocale        = locale;

            Logger.WriteLine("Version: {0}; Patch location: '{1}'; Locale: {2}", oldVersion, oldPatchLocation, oldLocale);

            switch (locale)
            {
            case 1: MapleClient = new MapleKorea(this, version, short.Parse(patchLocation)); break;

            case 7: MapleClient = new MapleSEA(this, version, short.Parse(patchLocation)); break;

            case 8:
                GMSKeys.Initialize();
                MapleClient = new MapleGlobal(this, version, short.Parse(patchLocation));
                break;
            }


            State = MapleState.WorldSelect;
            Logger.WriteLine("MapleClient: {0}", MapleClient.ToString());
            MapleClient.HandlingVersion = version;
            MapleClient.sendClientReady();

            Logger.WriteLine("Done");
            MapleClient.sendWorldListReRequest();
            connected = true;

            if (lostConnection && lastDisconnect != DateTime.MinValue && (DateTime.Now - lastDisconnect).TotalMinutes > 5)
            {
                TwitterClient.Instance.SendMessage("{0} downtime: {1} minutes", GetMapleStoryLocale(locale), (DateTime.Now - lastDisconnect).TotalMinutes);
            }
            lastDisconnect = DateTime.MinValue;

            lostConnection = false;
        }
示例#2
0
        static void Main(string[] args)
        {
            Logger.SetLogfile();
            TwitterClient.Load();
            mIlol          = 60;
            IgnoreDataTemp = false;

            if (args.Length >= 1)
            {
                Config.ConfigName = args[0];
            }

            Config.Load();
            try
            {
                DataBase.InitializeDataBase();
                if (Config.CreateTable)
                {
                    DataBase.CreateTable();
                    Config.CreateTable = false;
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorLog(ex.ToString());
                Logger.WriteLine("Incorrect database settings. {0}", ex.ToString());
                Console.ReadLine();
                Environment.Exit(1);
            }

            CRASHMODE = Config.Instance.CRASHMODE_ENABLE;

            //Config.Save();

            Connection = new MapleConnection(CRASHMODE ? 1000 : 60000);
            while (true)
            {
                string   line     = Console.ReadLine();
                string[] lineargs = line.Split(' ');
                switch (lineargs[0])
                {
                case "load": Logger.WriteLine("Current Load: {0}", Connection.AmountOnline); break;

                case "reconnect":
                    Logger.WriteLine("Starting reconnect...");
                    Connection.Disconnect();
                    Thread.Sleep(1000);
                    Connection.Connect();
                    break;

                case "forceload":
                    Logger.WriteLine("Forcing request...");
                    IgnoreDataTemp = true;
                    Connection.ForceRequest();
                    break;

                case "help":
                    Console.WriteLine("load");
                    Console.WriteLine("reconnect - Reconnecting to server");
                    Console.WriteLine("forceload - Forcing load request");
                    Console.WriteLine("sp [data] - Sends a packet with [data]");
                    Console.WriteLine("tweet [text] - Tweet a message with [text]");
                    Console.WriteLine("help - This stuff");
                    break;

                case "tweet":
                    TwitterClient.Instance.SendMessage(string.Join(" ", lineargs, 1, lineargs.Length - 1));
                    break;

                case "stop":
                case "exit":
                case "bye":
                case "close":
                    Environment.Exit(0);
                    break;

                case "reloadkeys":
                    GMSKeys.Initialize();
                    Logger.WriteLine("Reloaded keys");
                    break;

                case "sp":
                {
                    if (lineargs.Length > 1)
                    {
                        Packet pw = new Packet();
                        pw.WriteHexString(string.Join(" ", lineargs, 1, lineargs.Length - 1));
                        Connection.SendPacket(pw);
                    }
                    break;
                }

                default: Logger.WriteLine("Unknown command. Use help. Command: {0}", line); break;
                }
            }
        }