Beispiel #1
0
        public void execute(BaseSocketPacket data)
        {
            Dictionary <string, object> response = (Dictionary <string, object>)data.value;

            if (response.ContainsKey("result"))
            {
                int result = int.Parse(response["result"].ToString());
                if (result == 0)
                {
                    PWDataEditorPaied.PWAdmin.getInstance().unlockMaps("Operation was a success, acquiring new data!", false);
                    BaseSocketPacket         packet = new BaseSocketPacket();
                    HashMap <string, object> sd     = new HashMap <string, object>();
                    packet.module = Module.PWADMIN;
                    packet.cmd    = Cmd.STATUS;
                    sd["maps"]    = PWDataEditorPaied.PWAdmin.server_cache.GetMapsString();
                    packet.value  = sd;
                    if (Iobserver.instance() != null)
                    {
                        Iobserver.instance().send(packet);
                    }
                }
                else
                {
                    PWDataEditorPaied.PWAdmin.getInstance().unlockMaps("Operation was a failed, program now ready!");
                }
            }
        }
            public void RemoveObserver(Iobserver user)
            {
                int userIndex = ObserverList.IndexOf(user);

                if (ObserverList.Count > 0 && userIndex >= 0)
                {
                    ObserverList.RemoveAt(userIndex);
                }
            }
Beispiel #3
0
 public void Send(BaseSocketPacket packet)
 {
     if (baseSocket != null)
     {
         baseSocket.Send(packet);
     }
     else
     {
         if (Constants.drawBack)
         {
             SocketManager.missList.Add(packet);
         }
         Constants.Authed = false;
         if (Iobserver.instance() != null)
         {
             Iobserver.instance().init();
         }
     }
 }
Beispiel #4
0
        public void execute(BaseSocketPacket data)
        {
            Dictionary <string, object> response = (Dictionary <string, object>)data.value;


            if (response.ContainsKey("result"))
            {
                int result = Int32.Parse(response["result"].ToString());
                switch (result)
                {
                case 0:
                    ProfileView.instance().DologinDone();
                    if (Iobserver.instance() != null)
                    {
                        Iobserver.instance().close();
                    }
                    break;

                default:
                    ProfileView.instance().DologinDone();
                    break;
                }
            }
        }
Beispiel #5
0
 public void Quit(Iobserver observer)
 {
     playerList.Remove(observer);
     Console.WriteLine("Message:{0} exis {1} team", "12", this.AllyName);
 }
Beispiel #6
0
 public void addObserver(Iobserver observer)
 {
     allObservers.AddLast(observer);
 }
Beispiel #7
0
 public void addObservers(Iobserver o)
 {
     _observers.Add(o);
 }
Beispiel #8
0
 public bool removeObserver(Iobserver obs)
 {
     return(observerList.Remove(obs));
 }
Beispiel #9
0
 public void addObserver(Iobserver obs)
 {
     observerList.Add(obs);
 }
Beispiel #10
0
 /// <summary>
 /// 发布者提供给订阅者订阅改主题的方法
 /// </summary>
 /// <param name="observer"></param>
 public void Add(Iobserver observer)
 {
     list.Add(observer);
 }
Beispiel #11
0
        public void execute(BaseSocketPacket data)
        {
            Dictionary <string, object> response = (Dictionary <string, object>)data.value;

            if (response.ContainsKey("result"))
            {
                int result = Int32.Parse(response["result"].ToString());
                switch (result)
                {
                case 0:
                    if (!Constants.Authed && data.type == 3)
                    {
                        BaseSocketPacket         packet = new BaseSocketPacket();
                        HashMap <string, object> sd     = new HashMap <string, object>();
                        sd["buildId"] = Constants.build;
                        sd["yek"]     = Constants.ke;
                        sd["usr"]     = ProfileView.profile.userName;
                        sd["pwd"]     = ProfileView.profile.passWord;
                        sd["key"]     = ProfileView.profile.keyString;
                        packet.module = Module.USER;
                        packet.cmd    = Cmd.AUTH;
                        packet.value  = sd;
                        ProfileView.instance().progress_bar("Connected !", 0, 0);
                        if (Iobserver.instance() != null)
                        {
                            Iobserver.instance().send(packet);
                        }
                    }

                    if (data.type == 2 && response.ContainsKey("data") && Constants.Authed)
                    {
                        Dictionary <string, object> sysInfo = JsonConvert.DeserializeObject <Dictionary <string, object> >(response["data"].ToString());
                        foreach (KeyValuePair <string, object> datax in sysInfo)
                        {
                            String[]     demonData = JsonConvert.DeserializeObject <String[]>(datax.Value.ToString());
                            MessageClass msgc      = new MessageClass();
                            int          key       = Int32.Parse(datax.Key);
                            msgc.to      = demonData[0];
                            msgc.channel = demonData[2];
                            msgc.from    = demonData[1];

                            msgc.message = demonData[3];
                            msgc.time    = demonData[4];
                            PWAdmin.getInstance().add_chat_line(key, msgc);
                        }
                    }

                    break;

                case 100:
                    // INVALID_STRUCTURE_HWKEY
                    ProfileView.instance().progress_bar("Invalid password!", 0, 0);
                    Constants.canRecoonect = false;
                    if (Iobserver.instance() != null)
                    {
                        Iobserver.instance().close();
                    }
                    break;

                case 101:
                    // INVALID_BUILD
                    Constants.canRecoonect = false;
                    if (Iobserver.instance() != null)
                    {
                        Iobserver.instance().close();
                    }
                    break;

                case 102:
                    // INVALID_BUILD
                    ProfileView.instance().progress_bar("Not enough privileges!", 0, 0);
                    Constants.canRecoonect = false;
                    if (Iobserver.instance() != null)
                    {
                        Iobserver.instance().close();
                    }
                    break;
                }
            }
        }
Beispiel #12
0
 public void Join(Iobserver observer)
 {
     playerList.Add(observer);
     Console.WriteLine("Message:{0} join {1} team", "12", this.AllyName);
 }
Beispiel #13
0
 public void addObservers(Iobserver o) // хранилище добавляет подписчика
 {
     _observers.Add(o);
 }
Beispiel #14
0
        public void execute(BaseSocketPacket data)
        {
            Dictionary <string, object> response = (Dictionary <string, object>)data.value;

            if (response.ContainsKey("result"))
            {
                int result = Int32.Parse(response["result"].ToString());
                switch (result)
                {
                case 0:
                    PWAdmin.server_cache.reset();
                    Dictionary <string, object> game = new Dictionary <string, object>();
                    try
                    {
                        game = JsonConvert.DeserializeObject <Dictionary <string, object> > (response["game"].ToString());
                    }
                    catch { }

                    Dictionary <string, object> allMapsData = new Dictionary <string, object>();
                    if (game.ContainsKey("allMaps"))
                    {
                        allMapsData = JsonConvert.DeserializeObject <Dictionary <string, object> >(game["allMaps"].ToString());

                        foreach (KeyValuePair <string, object> datax in allMapsData)
                        {
                            int id = 0;
                            Int32.TryParse(datax.Value.ToString(), out id);
                            PWAdmin.server_cache.getMapByName(datax.Key).status = id;
                        }
                    }

                    Dictionary <string, object> demons_update = new Dictionary <string, object>();
                    if (game.ContainsKey("allDemons"))
                    {
                        demons_update = JsonConvert.DeserializeObject <Dictionary <string, object> >(game["allDemons"].ToString());
                    }

                    foreach (KeyValuePair <string, object> datax in demons_update)
                    {
                        try
                        {
                            String[] demonData = JsonConvert.DeserializeObject <String[]>(datax.ToString());
                            int      idd       = Int32.Parse(demonData[0]);
                            int      status    = Int32.Parse(demonData[1]);
                            PWAdmin.server_cache.updateDemonByID(idd, status);
                        }
                        catch { }
                    }


                    Dictionary <string, object> sysInfo = new Dictionary <string, object>();
                    if (response.ContainsKey("data"))
                    {
                        sysInfo = JsonConvert.DeserializeObject <Dictionary <string, object> >(response["data"].ToString());
                    }

                    foreach (KeyValuePair <string, object> datax in sysInfo)
                    {
                        try
                        {
                            switch (datax.Key)
                            {
                            case "availableProcessors":
                                PWAdmin.server_cache.numCores = datax.Value.ToString();
                                break;

                            case "getSystemCpuLoad":
                                PWAdmin.server_cache.ghzused = datax.Value.ToString();
                                break;
                            }
                        }
                        catch { }
                    }
                    if (game != null)
                    {
                        foreach (KeyValuePair <string, object> datax in game)
                        {
                            try
                            {
                                switch (datax.Key)
                                {
                                case "map_online_count":
                                    PWAdmin.server_cache.map_online_count = datax.Value.ToString();
                                    break;

                                case "totalAcc":
                                    PWAdmin.server_cache.totalAcc = datax.Value.ToString();
                                    break;

                                case "totalOnline":
                                    PWAdmin.server_cache.onlineAcc = datax.Value.ToString();
                                    break;

                                case "mem":
                                    String[] mem = JsonConvert.DeserializeObject <String[]>(datax.Value.ToString());
                                    PWAdmin.server_cache.ramfree  = mem[3];
                                    PWAdmin.server_cache.ramtotal = mem[1];
                                    PWAdmin.server_cache.ramused  = mem[2];
                                    break;

                                case "swp":
                                    String[] swp = JsonConvert.DeserializeObject <String[]>(datax.Value.ToString());
                                    PWAdmin.server_cache.swpfree  = swp[3];
                                    PWAdmin.server_cache.swptotal = swp[1];
                                    PWAdmin.server_cache.swpused  = swp[2];
                                    break;

                                case "CPUmhz":
                                    PWAdmin.server_cache.ghzmax = datax.Value.ToString();
                                    break;
                                }
                            }
                            catch { }
                        }
                    }
                    BaseSocketPacket         packet = new BaseSocketPacket();
                    HashMap <string, object> sd     = new HashMap <string, object>();
                    packet.module = Module.PWADMIN;
                    packet.cmd    = Cmd.ANALLMAPUPDATE;
                    sd["maps"]    = "";
                    packet.value  = sd;
                    if (Iobserver.instance() != null)
                    {
                        Iobserver.instance().send(packet);
                    }

                    PWAdmin.getInstance().update_serverStatus();
                    break;
                }
            }
        }
Beispiel #15
0
 public void RemoveCustomer(Iobserver user)
 {
     RemoveObserver(user);
 }
Beispiel #16
0
 //以下為包裝此Class 用的method
 public void RigestCustomer(Iobserver user)
 {
     RegisterObserver(user);
 }
Beispiel #17
0
        public void execute(BaseSocketPacket data)
        {
            Dictionary <string, object> response = (Dictionary <string, object>)data.value;


            if (response.ContainsKey("result"))
            {
                int result = Int32.Parse(response["result"].ToString());

                switch (result)
                {
                case 0:
                    if (response.ContainsKey("id"))
                    {
                        if (result == 0 && !response.ContainsKey("perm"))
                        {
                            ProfileView.instance().progress_bar("Not enough privileges!", 0, 0);
                            MessageBox.Show("Not enough privileges!");
                            Constants.canRecoonect = false;
                            if (Iobserver.instance() != null)
                            {
                                Iobserver.instance().close();
                            }
                            return;
                        }
                        int priv = Int32.Parse(response["perm"].ToString());
                        Constants.permission = priv;
                        if (Iobserver.instance() != null)
                        {
                            Iobserver.instance().registerCMDS(priv);
                        }
                        Dictionary <string, Dictionary <string, Object> > gmeAccounts = new Dictionary <string, Dictionary <string, Object> >();
                        try
                        {
                            Dictionary <string, Object> gmsacc = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, Object> >(response["GMS"].ToString());
                            foreach (KeyValuePair <string, Object> datax in gmsacc)
                            {
                                Dictionary <string, Object> dic = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, Object> >(datax.Value.ToString());
                                gmeAccounts.Add(datax.Key, dic);
                            }
                        }
                        catch
                        { }
                        ProfileView.gmeAccounts = gmeAccounts;


                        int playerID = Int32.Parse(response["id"].ToString());
                        Constants.Authed = true;
                        Constants.midb   = writeInt(playerID);
                        ProfileView.instance().progress_bar("Connected !", 0, 0);
                        ProfileView.instance().loginDone();
                    }
                    break;

                case 100:
                    // INVALID_STRUCTURE_HWKEY
                    ProfileView.instance().progress_bar("Invalid password!", 0, 0);
                    MessageBox.Show("Invalid password!");
                    Constants.canRecoonect = false;
                    if (Iobserver.instance() != null)
                    {
                        Iobserver.instance().close();
                    }
                    break;

                case 101:
                    // INVALID_BUILD
                    Constants.canRecoonect = false;
                    if (Iobserver.instance() != null)
                    {
                        Iobserver.instance().close();
                    }
                    break;

                case 102:
                    // INVALID_BUILD
                    ProfileView.instance().progress_bar("Invalid password!", 0, 0);
                    MessageBox.Show("Invalid password!");
                    Constants.canRecoonect = false;
                    if (Iobserver.instance() != null)
                    {
                        Iobserver.instance().close();
                    }
                    break;

                case 103:
                    ProfileView.instance().progress_bar("Not enough privileges!", 0, 0);
                    MessageBox.Show("Not enough privileges!");
                    Constants.canRecoonect = false;
                    if (Iobserver.instance() != null)
                    {
                        Iobserver.instance().close();
                    }
                    break;

                case 104:
                    ProfileView.instance().progress_bar("Already logged in!", 0, 0);
                    Constants.canRecoonect = false;
                    if (Iobserver.instance() != null)
                    {
                        Iobserver.instance().close();
                    }
                    MessageBox.Show("Already logged in!");
                    break;
                }
            }
        }
Beispiel #18
0
 public void RegisterObserver(Iobserver User)
 {
     ObserverList.Add(User);
 }