Пример #1
0
        public async Task SaveTodoItemAsync(REQ item, bool isNewItem = false)
        {
            // RestUrl = http://developer.xamarin.com:8081/  api/todoitems
            var uri = new Uri(string.Format(Constants.RestUrl, string.Empty));

            try {
                var json    = JsonConvert.SerializeObject(item);
                var content = new StringContent(json, Encoding.UTF8, "application/json");

                HttpResponseMessage response = null;
                if (isNewItem)
                {
                    response = await client.PostAsync(uri, content);
                }
                else
                {
                    response = await client.PutAsync(uri, content);
                }

                if (response.IsSuccessStatusCode)
                {
                    Debug.WriteLine(@"				TodoItem successfully saved.");
                }
            } catch (Exception ex) {
                Debug.WriteLine(@"				ERROR {0}", ex.Message);
            }
        }
Пример #2
0
        private bool ServerCommands(Account player, Room room)
        {
            try
            {
                if (text.StartsWith("(Ghost)"))
                {
                    text.Replace("(Ghost)", "");
                }
                if (text.StartsWith("(Fantasma)"))
                {
                    text.Replace("(Fantasma)", "");
                }
                string Command = text.Substring(1);
                if (!Settings.ChatCommandsActive || !player.HaveGMLevel())
                {
                    return(false);
                }
                if (!text.StartsWith(".") && text.Contains("help"))
                {
                    text = "Olha a merda...capoto o corsa. VRUMMMMM PÁH";
                    return(true);
                }
                if (!text.StartsWith("."))
                {
                    return(false);
                }
                Logger.ChatCommands($" [CHAT] [Commands] PlayerId: {player.playerId} Nick: {player.nickname} Login: {player.login} Ip: {player.ipAddress.ToString()} Text: {text}");

                AccessLevelEnum access = player.access;
                PacketCommand   REQ    = null;
                if (Command.StartsWith("HELP") && access >= AccessLevelEnum.Moderator)
                {
                    REQ = new CMD_HELP_REQ(1);
                }

                else if (Command.StartsWith("PCCAFEBASIC ") && access >= AccessLevelEnum.Admin)
                {
                    REQ = new CMD_GAMEMASTER_REQ(Command, 6);
                }
                else if (Command.StartsWith("PCCAFEPLUS ") && access >= AccessLevelEnum.Admin)
                {
                    REQ = new CMD_GAMEMASTER_REQ(Command, 7);
                }
                else if (Command.StartsWith("KICK ") && access >= AccessLevelEnum.Moderator)
                {
                    REQ = new CMD_KICK_REQ(Command, 1);
                }
                else if (Command.StartsWith("KICKALL") && access >= AccessLevelEnum.GameMaster)
                {
                    REQ = new CMD_KICK_REQ(Command, 2);
                }
                else if (Command.StartsWith("AFKKICK") && access >= AccessLevelEnum.Moderator)
                {
                    REQ = new CMD_KICK_REQ(Command, 2);
                }
                else if (Command.StartsWith("ONLINE") && access >= AccessLevelEnum.Moderator)
                {
                    REQ = new CMD_SERVERINFO_REQ(1);
                }
                else if (Command.StartsWith("G1 ") && access >= AccessLevelEnum.Moderator) //ALL
                {
                    REQ = new CMD_ANNOUNCE_REQ(Command, 1);
                }
                else if (Command.StartsWith("G2 ") && access >= AccessLevelEnum.Moderator) //ROOM
                {
                    REQ = new CMD_ANNOUNCE_REQ(Command, 2);
                }
                else if (Command.StartsWith("CASH ") && access >= AccessLevelEnum.GameMaster)
                {
                    REQ = new CMD_PLAYERINFO_REQ(Command, 1);
                }
                else if (Command.StartsWith("GOLD ") && access >= AccessLevelEnum.GameMaster)
                {
                    REQ = new CMD_PLAYERINFO_REQ(Command, 2);
                }
                else if (Command.StartsWith("RANK ") && access >= AccessLevelEnum.GameMaster)
                {
                    REQ = new CMD_GAMEMASTER_REQ(Command, 3);
                }
                else if (Command.StartsWith("NICK ") && access >= AccessLevelEnum.GameMaster)
                {
                    REQ = new CMD_GAMEMASTER_REQ(Command, 4);
                }
                else if (Command.StartsWith("ADDITEM ") && access >= AccessLevelEnum.GameMaster)
                {
                    REQ = new CMD_GAMEMASTER_REQ(Command, 5);
                }
                else if (Command.StartsWith("GMCOLOR") && access >= AccessLevelEnum.Moderator)
                {
                    REQ = new CMD_GAMEMASTER_REQ(Command, 1);
                }
                else if (Command.StartsWith("ANTIKICK") && access >= AccessLevelEnum.Moderator)
                {
                    REQ = new CMD_GAMEMASTER_REQ(Command, 2);
                }
                else if (Command.StartsWith("END") && access == AccessLevelEnum.Developer)
                {
                    REQ = new CMD_DEVELOPER_REQ(Command, 1);
                }
                else if (Command.StartsWith("ROOMTYPE ") && access == AccessLevelEnum.Developer)
                {
                    REQ = new CMD_DEVELOPER_REQ(Command, 2);
                }
                else if (Command.StartsWith("ROOMSPECIAL ") && access == AccessLevelEnum.Developer)
                {
                    REQ = new CMD_DEVELOPER_REQ(Command, 3);
                }
                else if (Command.StartsWith("ROOMWEAPON ") && access == AccessLevelEnum.Developer)
                {
                    REQ = new CMD_DEVELOPER_REQ(Command, 4);
                }
                else
                {
                    text = "Não foi possivel encontrar o comando digitado.";
                }
                if (REQ != null)
                {
                    if (REQ.Set(player, room))
                    {
                        REQ.RunImplement();
                    }
                    text = REQ.GetResponse();
                    REQ  = null;
                }
                return(true);
            }
            catch (Exception ex)
            {
                text = "Ocorreu um problema ao executar o comando.";
                Logger.Exception(ex);
                return(true);
            }
        }
 public DataServiceWrapper()
 {
     _req = new REQ <DataRequest, DataReply>("tcp://127.0.0.1:5050");
 }