Esempio n. 1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Methodes GBX ////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

        #region "GBX Methods"
        void connectXmlRpc()
        {
            int cpt = 0;

            while (cpt < TRY_AUTH_NB && !Lama.connected && Lama.launched)
            {
                cpt++;
                try
                {
                    this.client = new XmlRpcClient(this.adrs, this.port);
                    GbxCall authAnsw = this.client.Request(Authenticate, this.login, this.passwd);
                    if (authAnsw.Params[0].Equals(true)) //Auth success---------------------------------
                    {
                        this.client.EnableCallbacks(true);
                        this.client.EventGbxCallback          += new GbxCallbackHandler(gbxCallBack);
                        this.client.EventOnDisconnectCallback += new OnDisconnectHandler(gbxDisconnect);

                        Lama.connected = true; //exit loop
                    }
                }
                catch (Exception)
                {
                    System.Threading.Thread.Sleep(WAIT_AUTH_TIME);
                }
            }
        }
Esempio n. 2
0
        public List <Structs.MapList> GetMapList(int MaxResults, int StartIndex)
        {
            List <Structs.MapList> Result = new List <Structs.MapList>();

            GbxCall request = Client.Request("GetMapList", new object[] { MaxResults, StartIndex });

            GbxCall response = Client.GetResponse(request.Handle);

            if (response.Params.Count == 1 &&
                response.Params[0].GetType() == typeof(ArrayList))
            {
                foreach (Hashtable ht in (ArrayList)response.Params[0])
                {
                    Structs.MapList ml = new Structs.MapList();
                    ml.Author        = (string)ht["Author"];
                    ml.Environnement = (string)ht["Environnement"];
                    ml.FileName      = (string)ht["FileName"];
                    ml.MapStyle      = (string)ht["MapStyle"];
                    ml.Name          = (string)ht["Name"];
                    ml.UId           = (string)ht["UId"];
                    ml.GoldTime      = (int)ht["GoldTime"];
                    ml.CopperPrice   = (int)ht["CopperPrice"];
                    Result.Add(ml);
                }
            }

            return(Result);
        }
Esempio n. 3
0
        public List <Structs.PlayerList> GetPlayerList(int MaxResults, int StartIndex)
        {
            List <Structs.PlayerList> Result = new List <Structs.PlayerList>();

            GbxCall request = Client.Request("GetPlayerList", new object[] { MaxResults, StartIndex });

            GbxCall response = Client.GetResponse(request.Handle);

            if (response.Params.Count == 1 &&
                response.Params[0].GetType() == typeof(ArrayList))
            {
                foreach (Hashtable ht in (ArrayList)response.Params[0])
                {
                    Structs.PlayerList pl = new Structs.PlayerList();
                    pl.SpectatorStatus = (int)ht["SpectatorStatus"];
                    pl.Flags           = (int)ht["Flags"];
                    pl.LadderRanking   = (int)ht["LadderRanking"];
                    pl.PlayerId        = (int)ht["PlayerId"];
                    pl.TeamId          = (int)ht["TeamId"];
                    pl.Login           = (string)ht["Login"];
                    pl.Nickname        = (string)ht["NickName"];
                    Result.Add(pl);
                }
            }

            return(Result);
        }
Esempio n. 4
0
        protected override void onGbxAsyncResult(GbxCall res)
        {
            switch (res.MethodName)
            {
            case "ManiaPlanet.ServerStart":

                break;
            }
        }
Esempio n. 5
0
        private Hashtable GetCurrentMapInfo(XmlRpcClient client)
        {
            GbxCall gbxCall = client.Request("GetCurrentMapInfo", new object[0]);

            if (gbxCall.HasError == false)
            {
                return(gbxCall.Params[0] as Hashtable);
            }

            return(new Hashtable());
        }
Esempio n. 6
0
 public override void onGbxAsyncResult(GbxCall res)
 {
     if (this.handles.ContainsKey(res.Handle))
     {
         switch (this.handles[res.Handle])
         {
         case "":
             break;
         }
     }
 }
Esempio n. 7
0
        public String GetServerName()
        {
            GbxCall request = Client.Request("GetServerName", new object[] { });

            GbxCall response = Client.GetResponse(request.Handle);

            if (response.Params.Count == 1)
            {
                return(response.Params[0].ToString());
            }
            else
            {
                return(String.Empty);
            }
        }
Esempio n. 8
0
        public Boolean Authenticate(String Username, String Password)
        {
            GbxCall request = Client.Request("Authenticate", new object[] { Username, Password });

            GbxCall response = Client.GetResponse(request.Handle);

            if (response.Params.Count == 1)
            {
                return((bool)response.Params[0]);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 9
0
        private Tuple <string, ushort> GetServerOptions(XmlRpcClient client)
        {
            GbxCall gbxCall = client.Request("GetServerOptions", new object[0]);

            if (gbxCall.HasError == false)
            {
                var hashTable = gbxCall.Params[0] as Hashtable;

                if (hashTable != null)
                {
                    return(new Tuple <string, ushort>(hashTable["Name"] as string, Convert.ToUInt16(hashTable["CurrentMaxPlayers"])));
                }
            }

            return(new Tuple <string, ushort>(default(string), default(ushort)));
        }
Esempio n. 10
0
        private ushort?GetPlayerCount(XmlRpcClient client, int maxCount, int firstIndex, int structVersion = 1)
        {
            GbxCall gbxCall = client.Request("GetPlayerList", new object[]
            {
                maxCount,
                firstIndex,
                structVersion
            });

            if (gbxCall.HasError == false)
            {
                return((ushort?)(gbxCall.Params[0] as ArrayList)?.Count);
            }

            return(0);
        }
Esempio n. 11
0
        public override TrackManiaServerInfo GetServerInfo()
        {
            using (var requestClient = new XmlRpcClient(this.endPoint))
            {
                GbxCall gbxCall = requestClient.Request("Authenticate", new object[]
                {
                    this.user,
                    this.password
                });

                if (gbxCall.HasError == false && gbxCall.Params[0].Equals(true))
                {
                    var count         = this.GetPlayerCount(requestClient, 256, 0).GetValueOrDefault(0);
                    var mapInfo       = this.GetCurrentMapInfo(requestClient);
                    var serverOptions = this.GetServerOptions(requestClient);

                    if (mapInfo.Count > 0)
                    {
                        return(new TrackManiaServerInfo
                        {
                            Name = serverOptions.Item1,
                            CurrentMapName = mapInfo["Name"] as string,
                            CurrentMaxPlayers = serverOptions.Item2,
                            CurrentPlayerCount = count,
                            MapType = mapInfo["MapType"] as string,
                            Mood = mapInfo["Mood"] as string,
                            Environment = mapInfo["Environment"] as string,
                            CopperPrice = Convert.ToUInt32(mapInfo["CopperPrice"]),
                            LapRace = Convert.ToBoolean(mapInfo["LapRace"]),
                            BronzeTime = Convert.ToUInt32(mapInfo["BronzeTime"]),
                            SilverTime = Convert.ToUInt32(mapInfo["SilverTime"]),
                            GoldTime = Convert.ToUInt32(mapInfo["GoldTime"]),
                            UId = mapInfo["UId"] as string,
                            NbCheckpoints = Convert.ToUInt16(mapInfo["NbCheckpoints"]),
                            NbLaps = Convert.ToUInt16(mapInfo["NbLaps"]),
                            FileName = mapInfo["FileName"] as string,
                            Author = mapInfo["Author"] as string,
                            MapStyle = mapInfo["MapStyle"] as string,
                            AuthorTime = Convert.ToUInt32(mapInfo["AuthorTime"])
                        });
                    }
                }

                return(new TrackManiaServerInfo());
            }
        }
Esempio n. 12
0
        public ShootManiaXMLRPC.Structs.ServerStatus GetStatus()
        {
            GbxCall request = Client.Request("GetStatus", new object[] {  });

            GbxCall response = Client.GetResponse(request.Handle);

            if (response.Params.Count == 1 &&
                response.Params[0].GetType() == typeof(Hashtable))
            {
                Hashtable            ht = (Hashtable)response.Params[0];
                Structs.ServerStatus ss = new Structs.ServerStatus();
                ss.Code = (int)ht["Code"];
                ss.Name = (string)ht["Name"];
                return(ss);
            }

            return(new Structs.ServerStatus());
        }
Esempio n. 13
0
        public ShootManiaXMLRPC.Structs.ScriptName GetScriptName()
        {
            GbxCall request = Client.Request("GetScriptName", new object[] { });

            GbxCall response = Client.GetResponse(request.Handle);

            if (response.Params.Count == 1 &&
                response.Params[0].GetType() == typeof(Hashtable))
            {
                Hashtable          ht = (Hashtable)response.Params[0];
                Structs.ScriptName sn = new Structs.ScriptName();
                sn.CurrentValue = (string)ht["CurrentValue"];
                sn.NextValue    = (string)ht["NextValue"];
                return(sn);
            }

            return(new Structs.ScriptName());
        }
Esempio n. 14
0
        public override void onGbxAsyncResult(GbxCall res)
        {
            if (res.Error)
            {
                switch (this.handles[res.Handle])
                {
                case "GetBanList":
                    break;
                }
            }
            else //Error
            {
                string errStr = "[" + this.PluginName + "]" + res.ErrorCode + " : " + res.ErrorString;

                Log("ERROR", errStr);           //Log file
                OnError(this, "Error", errStr); //Show error dialog
            }
        }
Esempio n. 15
0
        private IReadOnlyCollection <TrackManiaPlayerInfo> GetPlayers(XmlRpcClient client, int maxCount, int firstIndex, int structVersion = 1)
        {
            GbxCall gbxCall = client.Request("GetPlayerList", new object[]
            {
                maxCount,
                firstIndex,
                structVersion
            });

            if (gbxCall.HasError == false)
            {
                var playerList = gbxCall.Params[0] as ArrayList;

                if (playerList != null)
                {
                    var players = new List <TrackManiaPlayerInfo>();

                    for (byte i = 0; i < playerList.Count; i++)
                    {
                        var playerData = playerList[i] as Hashtable;

                        if (playerData != null)
                        {
                            players.Add(new TrackManiaPlayerInfo
                            {
                                Index           = i,
                                Flags           = playerData["Flags"] as int? ?? 0,
                                TeamId          = playerData["TeamId"] as int? ?? 0,
                                Login           = playerData["Login"] as string,
                                NickName        = playerData["NickName"] as string,
                                SpectatorStatus = playerData["SpectatorStatus"] as byte? ?? 0,
                                PlayerId        = playerData["PlayerId"] as int? ?? 0,
                                LadderRanking   = playerData["LadderRanking"] as int? ?? 0
                            });
                        }
                    }

                    return(players);
                }
            }

            return(new List <TrackManiaPlayerInfo>());
        }
Esempio n. 16
0
        public Structs.MaxSpectators GetMaxSpectators()
        {
            GbxCall request = Client.Request("GetMaxSpectators", new object[] { });

            GbxCall response = Client.GetResponse(request.Handle);

            if (response.Params.Count == 1 &&
                response.Params[0].GetType() == typeof(Hashtable))
            {
                Hashtable             ht = (Hashtable)response.Params[0];
                Structs.MaxSpectators ms = new Structs.MaxSpectators();
                ms.CurrentValue = (int)ht["CurrentValue"];
                ms.NextValue    = (int)ht["NextValue"];
                return(ms);
            }
            else
            {
                return(new Structs.MaxSpectators());
            }
        }
Esempio n. 17
0
        public List <String> GetChatLines()
        {
            List <String> Result = new List <String>();

            GbxCall request = Client.Request("GetChatLines", new object[] { });

            GbxCall response = Client.GetResponse(request.Handle);

            foreach (object o in response.Params)
            {
                if (o.GetType() == typeof(ArrayList))
                {
                    ArrayList Lines = (ArrayList)o;
                    foreach (var line in Lines)
                    {
                        Result.Add(line.ToString());
                    }
                }
            }

            return(Result);
        }
Esempio n. 18
0
        public List <Structs.BanList> GetBanList(int MaxResults, int StartIndex)
        {
            List <Structs.BanList> Result = new List <Structs.BanList>();

            GbxCall request = Client.Request("GetBanList", new object[] { MaxResults, StartIndex });

            GbxCall response = Client.GetResponse(request.Handle);

            if (response.Params.Count == 1 &&
                response.Params[0].GetType() == typeof(ArrayList))
            {
                foreach (Hashtable ht in (ArrayList)response.Params[0])
                {
                    Structs.BanList bl = new Structs.BanList();
                    bl.Login      = (string)ht["Login"];
                    bl.ClientName = (string)ht["ClientName"];
                    bl.IPAddress  = (string)ht["IPAddress"];
                    Result.Add(bl);
                }
            }

            return(Result);
        }
Esempio n. 19
0
        public ShootManiaXMLRPC.Structs.CurrentMapInfo GetCurrentMapInfo()
        {
            GbxCall request = Client.Request("GetCurrentMapInfo", new object[] { });

            GbxCall response = Client.GetResponse(request.Handle);

            if (response.Params.Count == 1 &&
                response.Params[0].GetType() == typeof(Hashtable))
            {
                Hashtable ht = (Hashtable)response.Params[0];
                Structs.CurrentMapInfo cmi = new Structs.CurrentMapInfo();
                cmi.Author        = (string)ht["Author"];
                cmi.Environnement = (string)ht["Environnement"];
                cmi.FileName      = (string)ht["FileName"];
                cmi.MapStyle      = (string)ht["MapStyle"];
                cmi.Name          = (string)ht["Name"];
                cmi.UId           = (string)ht["UId"];
                cmi.GoldTime      = (int)ht["GoldTime"];
                cmi.CopperPrice   = (int)ht["CopperPrice"];
                return(cmi);
            }

            return(new Structs.CurrentMapInfo());
        }
Esempio n. 20
0
 public void ChatSendToLogin(String Login, String Text)
 {
     GbxCall request = Client.Request("ChatSendToLogin", new object[] { Login, Text, "''" });
 }
Esempio n. 21
0
 public void SendNoticeToLogin(String Login, String Text)
 {
     GbxCall request = Client.Request("SendNoticeToLogin", new object[] { Login, Text, "''" });
 }
Esempio n. 22
0
 public void SetScriptName(String ScriptName)
 {
     GbxCall request = Client.Request("SetScriptName", new object[] { ScriptName });
 }
Esempio n. 23
0
 public void SetServerPasswordForSpectator(String Password)
 {
     GbxCall request = Client.Request("SetServerPasswordForSpectator", new object[] { Password });
 }
Esempio n. 24
0
 public void SetServerName(String Comment)
 {
     GbxCall request = Client.Request("SetServerName", new object[] { Comment });
 }
Esempio n. 25
0
 public void UnBan(String ClientName)
 {
     GbxCall request = Client.Request("UnBan", new object[] { ClientName });
 }
Esempio n. 26
0
 public void SetApiVersion(String Version)
 {
     GbxCall request = Client.Request("SetApiVersion", new object[] { Version });
 }
Esempio n. 27
0
 public void ChooseNextMap(String Filename)
 {
     GbxCall request = Client.Request("ChooseNextMap", new object[] { Filename });
 }
Esempio n. 28
0
 public void BanId(Int32 PlayerId, String Message)
 {
     GbxCall request = Client.Request("BanId", new object[] { PlayerId, Message });
 }
Esempio n. 29
0
 public void RestartMap(Boolean DontClearCupScores)
 {
     GbxCall request = Client.Request("RestartMap", new object[] { DontClearCupScores });
 }
Esempio n. 30
0
 public void SetMaxSpectators(Int32 MaxSpectators)
 {
     GbxCall request = Client.Request("SetMaxSpectators", new object[] { MaxSpectators });
 }