Exemplo n.º 1
0
        public static void F_INTERFACE_COMMAND(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (cclient.Plr == null)
                return;

            byte CommandId = packet.GetUint8();

            switch (CommandId)
            {

                case 1: // ????
                    {
                    } break;

                case 2: // Resurrect Button
                    {
                        cclient.Plr.PreRespawnPlayer();
                        Log.Success("Interface Command", "Respawn Player");
                    } break;

                case 10: // Talisman Fuse
                    {
                    } break;

            };
        }
Exemplo n.º 2
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     LobbyClient cclient = client as LobbyClient;
     UInt32 WorldUid = packet.GetUint32Reversed();
     string Name = packet.GetParsedString();
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_NAME_CHECK);
     if (Databases.CharacterTable.Count(c => c.Name == Name) == 0)
     {
         cclient.Pending = new CharacterEntry();
         cclient.Pending.Index = Databases.CharacterTable.GenerateIndex();
         cclient.Pending.AccountIndex = cclient.Account.Index;
         cclient.Pending.Name = Name;
         cclient.Pending.World = (int)WorldUid;
         cclient.Pending.Rank = 1;
         cclient.Pending.Money = 0;
         cclient.Pending.Threat = 1;
         cclient.Pending.Playtime = 0;
         cclient.Pending.Clan = "APB-EMU";
         cclient.Pending.IsOnline = 0;
         cclient.Pending.DistrictID = 0;
         cclient.Pending.DistrictType = 0;
         cclient.Pending.LFG = 0;
         cclient.Pending.IsGroupPublic = 0;
         cclient.Pending.GroupInvite = 0;
         cclient.Pending.GroupStatus = 0;
         Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
     }
     else
     {
         cclient.Pending = default(CharacterEntry);
         Out.WriteUInt32Reverse((uint)ResponseCodes.RC_CHARACTER_NAME_CHECK_IN_USE);
     }
     cclient.Send(Out);
     return 0;
 }
Exemplo n.º 3
0
        public static void F_FLIGHT(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            UInt16 TargetOID = packet.GetUint16();
            UInt16 State = packet.GetUint16();

            Log.Info("F_FLIGHT", "TargetOid = " + TargetOID + ",State=" + State);

            if (State == 20) // Flight Master
            {
                Object Obj = cclient.Plr.Zone.GetObject(TargetOID);
                if (Obj == null || !Obj.IsCreature())
                {
                    Log.Error("F_FLIGHT", "Invalid Creature OID : " + TargetOID);
                    return;
                }

                UInt16 FlyID = packet.GetUint16();

                List<Zone_Taxi> Taxis = WorldMgr.GetTaxis(cclient.Plr);
                if (Taxis.Count <= FlyID - 1)
                    return;

                if (!cclient.Plr.RemoveMoney(Taxis[FlyID - 1].Info.Price))
                {
                    cclient.Plr.SendLocalizeString("", GameData.Localized_text.TEXT_MERCHANT_INSUFFICIENT_MONEY_TO_BUY);
                    return;
                }

                cclient.Plr.Teleport(Taxis[FlyID - 1].ZoneID, Taxis[FlyID - 1].WorldX, Taxis[FlyID - 1].WorldY, Taxis[FlyID - 1].WorldZ, Taxis[FlyID - 1].WorldO);
            }
        }
Exemplo n.º 4
0
        static public void F_USE_ITEM(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;
            if (!cclient.IsPlaying())
                return;

            Player Plr = cclient.Plr;

            ushort slot = packet.GetUint16();

            Item item = Plr.ItmInterface.GetItemInSlot(slot);

            if (Plr.Level < item.Info.MinRank)
            {
                Plr.SendLocalizeString("", GameData.Localized_text.TEST_ITEM_PLAYER_LEVEL_TOO_LOW);
                return;
            }
            else if (Plr.Rank < item.Info.MinRenown)
            {
                Plr.SendLocalizeString("", GameData.Localized_text.TEST_ITEM_PLAYER_RENOWN_TOO_LOW);
                return;
            }

            if (item.Info.Type == 31 && item.Info.ScriptName == "HealthPotion") // Potion
            {
                Plr.DealHeal(Plr, (uint)item.Info.MinRank * 100);
                Plr.ItmInterface.DeleteItem(slot, 1, true);
            }
            
        }
Exemplo n.º 5
0
        static public void CL_CHECK(BaseClient client, PacketIn packet)
        {
            Client cclient = client as Client;
            uint Version = packet.GetUint32();

            Log.Debug("CL_CHECK", "Launcher Version : " + Version);

            PacketOut Out = new PacketOut((byte)Opcodes.LCR_CHECK);

            if (Version != Program.Version)
            {
                Out.WriteByte((byte)CheckResult.LAUNCHER_VERSION); // Version incorrect + message
                Out.WriteString(Program.Message);
                client.SendPacket(Out);

                cclient.Disconnect();
                return;
            }

            byte File = packet.GetUint8();
            UInt64 Len = 0;

            if (File >= 1)
                Len = packet.GetUint64();

            if ((long)Len != Program.Info.Length)
            {
                Out.WriteByte((byte)CheckResult.LAUNCHER_FILE);
                Out.WriteString(Program.StrInfo);
            }
            else
                Out.WriteByte((byte)CheckResult.LAUNCHER_OK);

            cclient.SendPacket(Out);
        }
Exemplo n.º 6
0
        public static void F_BAG_INFO(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (!cclient.IsPlaying())
                return;

            byte Type = packet.GetUint8();

            Player Plr = cclient.Plr;

            switch (Type)
            {
                case 3: // Toggle Pvp
                    Plr.CbtInterface.TogglePvp();
                    break;

                case 16: // Buy more bag space
                    byte Price = packet.GetUint8();
                    if (!Plr.ItmInterface.HasMaxBag())
                    {
                        if (Plr.HaveMoney(Plr.ItmInterface.GetBagPrice()))
                        {
                            if (Plr.RemoveMoney(Plr.ItmInterface.GetBagPrice()))
                            {
                                ++Plr.ItmInterface.BagBuy;
                                Plr.ItmInterface.SendMaxInventory(Plr);
                            }
                        }
                    }
                    break;
            }
        }
Exemplo n.º 7
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     WorldClient cclient = (WorldClient)client;
     UInt32 code = packet.GetUint32();
     cclient.Send(new ANS_DISTRICT_RESERVE(code, packet.GetUint32(), cclient.Character.LFG, cclient));
     return 0;
 }
Exemplo n.º 8
0
        static public void CMSG_VerifyProtocolReq(BaseClient client, PacketIn packet)
        {
            Client cclient = client as Client;

            PacketOut Out = new PacketOut((byte)Opcodes.SMSG_VerifyProtocolReply);

            byte[] IV_HASH1 = { 0x01, 0x53, 0x21, 0x4d, 0x4a, 0x04, 0x27, 0xb7, 0xb4, 0x59, 0x0f, 0x3e, 0xa7, 0x9d, 0x29, 0xe9 };
            byte[] IV_HASH2 = { 0x49, 0x18, 0xa1, 0x2a, 0x64, 0xe1, 0xda, 0xbd, 0x84, 0xd9, 0xf4, 0x8a, 0x8b, 0x3c, 0x27, 0x20 };
            
            ByteString iv1 = ByteString.CopyFrom(IV_HASH1);
            ByteString iv2 = ByteString.CopyFrom(IV_HASH2);
            VerifyProtocolReply.Builder verify = VerifyProtocolReply.CreateBuilder();
            verify.SetResultCode(VerifyProtocolReply.Types.ResultCode.RES_SUCCESS);

            verify.SetIv1(ByteString.CopyFrom(IV_HASH1));
            verify.SetIv2(ByteString.CopyFrom(IV_HASH2));


            
            Out.Write(verify.Build().ToByteArray());
   

            cclient.SendTCPCuted(Out);

        }
Exemplo n.º 9
0
        public static void F_INTERACT(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (cclient.Plr == null || !cclient.Plr.IsInWorld())
                return;

            Log.Dump("F_INTERACT", packet.ToArray(), 0, packet.ToArray().Length);

            InteractMenu Menu = new InteractMenu();
            Menu.Unk = packet.GetUint16();
            Menu.Oid = packet.GetUint16();
            Menu.Menu = packet.GetUint16();
            Menu.Page = packet.GetUint8();
            Menu.Num = packet.GetUint8();
            Menu.SellCount = packet.GetUint16();
            Menu.Count = packet.GetUint16();

            Object Obj = cclient.Plr.Region.GetObject(Menu.Oid);
            if (Obj == null)
                return;

            if (Obj.GetDistanceTo(cclient.Plr) > 20)
            {
                Log.Error("F_INTERACT", "Distance = " + Obj.GetDistanceTo(cclient.Plr));
                return;
            }

            Obj.SendInteract(cclient.Plr, Menu);
        }
Exemplo n.º 10
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     LobbyClient cclient = (LobbyClient)client;
     Byte slotId = packet.GetUint8();
     Character character = cclient.Characters.Get(slotId);
     if (character == null) Log.Error(cclient.Account.Email, "Wrong slot specified!");
     World.World info = null;
     lock (Program.worldListener.Worlds)
     {
         Program.worldListener.Worlds.TryGetValue(character.WorldId, out info);
     }
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_WORLD_ENTER);
     if (info == null) Out.WriteUInt32Reverse(1);
     else
     {
         info.Send(new AccountEnter(cclient.Account.Id, character.Id, cclient.SessionId));
         Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
         Out.WriteByte(info.IP1);
         Out.WriteByte(info.IP2);
         Out.WriteByte(info.IP3);
         Out.WriteByte(info.IP4);
         Out.WriteUInt16Reverse((UInt16)info.Port);
         Out.WriteInt64Reverse(TCPManager.GetTimeStamp());
     }
     cclient.Send(Out);
     return 0;
 }
Exemplo n.º 11
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     LobbyClient cclient = (LobbyClient)client;
     Byte slotId = packet.GetUint8();
     CharacterEntry character = Databases.CharacterTable.SingleOrDefault(c => c.AccountIndex == cclient.Account.Index && c.Slot == slotId);
     if (character.Index < 1) Log.Error(cclient.Account.Username, "Wrong slot specified!");
     World.World info = null;
     lock (Program.worldListener.Worlds)
     {
         Program.worldListener.Worlds.TryGetValue((uint)character.World, out info);
     }
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_WORLD_ENTER);
     if (info == null) Out.WriteUInt32Reverse(1);
     else
     {
         info.Send(new AccountEnter((uint)cclient.Account.Index, (uint)character.Index, cclient.SessionId));
         Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
         Out.WriteByte(info.IP1);
         Out.WriteByte(info.IP2);
         Out.WriteByte(info.IP3);
         Out.WriteByte(info.IP4);
         Out.WriteUInt16Reverse((UInt16)info.Port);
         Out.WriteInt64Reverse(TCPManager.GetTimeStamp());
     }
     cclient.Send(Out);
     return 0;
 }
Exemplo n.º 12
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     LobbyClient cclient = client as LobbyClient;
     byte[] clientModulus = new byte[64];
     for (int i = 0; i < 64; ++i) clientModulus[i] = packet.GetUint8();
     cclient.clientModulus = new FrameWork.NetWork.Crypto.BigInteger(1, clientModulus);
     UInt16 unk = packet.GetUint16();
     byte[] Proof = new byte[20];
     for (int i = 0; i < 20; ++i) Proof[i] = packet.GetUint8();
     cclient.Proof = Proof;
     if (IsBanned(cclient))
     {
         ANS_LOGIN_FAILED.Send(cclient, (int)ResponseCodes.RC_LOGIN_ACCOUNT_BLOCKED);
         cclient.Disconnect();
     }
     else
     {
         if (IsValid(cclient))
         {
             ANS_LOGIN_SUCCES.Send(cclient);
             cclient.ECrypt = new TCP.Encryption(cclient.SessionId);
             ANS_CHARACTER_INFO.Send(cclient);
         }
         else
         {
             ANS_LOGIN_FAILED.Send(cclient, (int)ResponseCodes.RC_LOGIN_INVALID_ACCOUNT);
             cclient.Disconnect();
         }
     }
     return 0;
 }
        public static void HandlePacket(BaseClient client, PacketIn packet)
        {
            LobbyClient cclient = (LobbyClient)client;

            UInt32 WorldUid = packet.GetUint32R();
            string Name = packet.GetUnicodeString();

            PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_NAME_CHECK);

            if (CheckName(Name) == 0)
            {
                cclient.CreateChar = new DBCharacter();
                cclient.CreateChar.AcctId = cclient.Account.Id;
                cclient.CreateChar.Name = Name;

                if (cclient.Account.WorldId != WorldUid)
                    Program.CharMgr.SetAccountWorld(cclient.Account.Id, (int)WorldUid);

                Out.WriteUInt32(0);
            }
            else
            {
                cclient.CreateChar = null;
                Out.WriteUInt32(1);
            }

            cclient.SendTCP(Out);
        }
Exemplo n.º 14
0
        public static void HandlePacket(BaseClient client, PacketIn packet)
        {
            LobbyClient cclient = client as LobbyClient;

            byte freeslot = Program.CharMgr.GetFreeSlot(cclient.Account.Id);

            if (freeslot == 0 || cclient.CreateChar == null)
                ANS_CHARACTER_CREATE.Send(cclient);
            else
            {
                cclient.CreateChar.SlotId = freeslot;
                cclient.CreateChar.Faction = packet.GetUint8();
                cclient.CreateChar.Gender = packet.GetUint8();
                cclient.CreateChar.Version = (int)packet.GetUint32R();
                cclient.CreateChar.Seconds = (int)packet.GetUint32R();

                byte[] Custom = new byte[packet.Length - packet.Position];
                packet.Read(Custom, 0, Custom.Length);

                cclient.CreateChar.Custom = BitConverter.ToString(Custom);

                Program.CharMgr.CreateCharacter(cclient.CreateChar);
                ANS_CHARACTER_CREATE.Send(cclient);
            }
        }
Exemplo n.º 15
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     LobbyClient cclient = client as LobbyClient;
     byte slotId = packet.GetUint8();
     Character Info = cclient.Characters.Get(slotId);
     MySqlCommand cmd = new MySqlCommand("DELETE FROM `clientstatus` WHERE `name` = @name", Connection.Instance);
     try
     {
         cmd.Prepare();
         cmd.Parameters.AddWithValue("@name", Info.Name);
         cmd.ExecuteNonQuery();
     }
     catch (MySqlException) { }
     finally { cmd.Dispose(); }
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_INFO);
     if (Info == null) Out.WriteUInt32Reverse((uint)ResponseCodes.RC_FAILED);
     else
     {
         Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
         Out.WriteByte(Info.Slot);
         Out.WriteByte(Info.Gender);
         Out.WriteUInt32Reverse(Info.Playtime);
         Out.WriteUInt32Reverse(Info.Rank);
         Out.WriteByte(Info.Threat);
         Out.WriteUInt32Reverse(Info.Money);
         Out.WriteParsedString("APB-EMU", 60);
         byte[] Custom = Info.getCustom();
         Out.Write(Custom, 0, Custom.Length);
     }
     cclient.Send(Out);
     return 0;
 }
Exemplo n.º 16
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     WorldClient cclient = (WorldClient)client;
     PacketOut Out = new PacketOut((UInt32)Opcodes.LFG);
     if (cclient.LFG == 0)
     {
         MySqlCommand cmd = new MySqlCommand("UPDATE `clientstatus` SET `lfg` = 1 WHERE `name` = @name", WorldServer.Database.Connection.Instance);
         try
         {
             cmd.Prepare();
             cmd.Parameters.AddWithValue("@name", cclient.Name);
             cmd.ExecuteNonQuery();
         }
         catch (MySqlException e) { FrameWork.Logger.Log.Error("MySQL", e.ToString()); }
         finally { cmd.Dispose(); }
         cclient.LFG = 1;
         Out.WriteByte(1);
     }
     else if (cclient.LFG == 1)
     {
         MySqlCommand cmd = new MySqlCommand("UPDATE `clientstatus` SET `lfg` = 0 WHERE `name` = @name", WorldServer.Database.Connection.Instance);
         try
         {
             cmd.Prepare();
             cmd.Parameters.AddWithValue("@name", cclient.Name);
             cmd.ExecuteNonQuery();
         }
         catch (MySqlException e) { FrameWork.Logger.Log.Error("MySQL", e.ToString()); }
         finally { cmd.Dispose(); }
         cclient.LFG = 0;
         Out.WriteByte(0);
     }
     cclient.Send(Out);
     return 0;
 }
Exemplo n.º 17
0
        public static void F_TRADE_STATUS(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;
            if (!cclient.IsPlaying())
                return;

            cclient.Plr.ItmInterface.HandleTrade(packet);
        }
Exemplo n.º 18
0
        static public void F_SWITCH_ATTACK_MODE(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;
            if (!cclient.HasPlayer())
                return;

            cclient.Plr.CbtInterface.Attacking = true;
        }
        /// <summary>
        /// Returns the information for a given Eloqua account.
        /// </summary>
        /// <param name="site">
        /// The site for accessing Eloqua services, this is tipically the company name. This is the same used to access
        /// Eloqua website.
        /// </param>
        /// <param name="user">The username. This is the same used to access Eloqua website.</param>
        /// <param name="password">The password of the account. This is the same used to access Eloqua website.</param>
        /// <returns>The information for the given account. It is directly retrieved from Eloqua.</returns>
        public static async Task<AccountInfo> GetAccountInfoAsync(string site, string user, string password)
        {
            var client = new BaseClient(site, user, password, BulkUrl.Login);

            IRestResponse<AccountInfo> responseAccountInfo =
                await client.ExecuteTaskAsync<AccountInfo>(new RestRequest("id", Method.GET));

            return responseAccountInfo.Data;
        }
Exemplo n.º 20
0
        public static void HandlePacket(BaseClient client, PacketIn packet)
        {
            LobbyClient cclient = client as LobbyClient;
            Program.CharMgr.DeleteCharacter(cclient.Account.Id, packet.GetUint8());

            PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_DELETE);
            Out.WriteUInt32R(0);
            cclient.SendTCP(Out);
        }
Exemplo n.º 21
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     LobbyClient cclient = client as LobbyClient;
     cclient.Characters.Delete(packet.GetUint8());
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_DELETE);
     Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
     cclient.Send(Out);
     return 0;
 }
Exemplo n.º 22
0
        /// <summary>
        /// Executes the handlers for a specified request type.
        /// </summary>
        /// <param name="key">The request type.</param>
        /// <param name="client">Client on which to execute handler; provided in event delegate.</param>
        /// <param name="e">Desired event arguments.</param>
        public void ExecuteHandler(short key, BaseClient client, RequestReceivedEventArgs e)
        {
            ClientEventHandler<RequestReceivedEventArgs> value;

            if (TryGetValue(key, out value))
            {
                value.Invoke(client, e);
            }
        }
Exemplo n.º 23
0
        public static void F_INTERRUPT(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (cclient.Plr == null)
                return;

            cclient.Plr.AbtInterface.StopCast();
        }
Exemplo n.º 24
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     WorldClient cclient = (WorldClient)client;
     UInt32 whisperuid = packet.GetUint32Reversed();
     String charname = packet.GetParsedString();
     String message = packet.GetParsedString();
     (client as WorldClient).Send(new ANS_CHAT_WHISPER(cclient, whisperuid, charname, message));
     //cclient.Send(new CHAT_WHISPER(cclient.CharacterId, 1, message));
     return 0;
 }
Exemplo n.º 25
0
        public static void HandlePacket(BaseClient client, PacketIn packet)
        {
            LobbyClient cclient = client as LobbyClient;
            packet.Skip(24);
            string Email = packet.GetUnicodeString().ToUpper();

            Log.Notice("ASK_LOGIN", "Authentification de : " + Email);

            SendLoginResult(cclient, Email,Program.CharMgr.LoadAccount(Email));
        }
Exemplo n.º 26
0
        static public void CMSG_GetAcctPropListReq(BaseClient client, PacketIn packet)
        {
            Client cclient = client as Client;

            PacketOut Out = new PacketOut((byte)Opcodes.SMSG_GetAcctPropListReply);
            byte[] val = { 0x08, 0x00 };
            Out.Write(val);
            cclient.SendTCPCuted(Out);

        }
Exemplo n.º 27
0
        public static void Init(string apiKey)
        {
            if (string.IsNullOrEmpty(apiKey))
            {
                Log.WriteWarn("Error Reporter", "API key is empty, errors will not be sent to Bugsnag.");

                return;
            }

            Client = new BaseClient(apiKey);
        }
Exemplo n.º 28
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     LobbyClient cclient = (LobbyClient)client;
     byte FileId = packet.GetUint8();
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CONFIGFILE_LOAD);
     Out.WriteInt32Reverse((int)ResponseCodes.RC_SUCCESS);
     Out.WriteByte(FileId);
     byte[] Result = ZlibMgr.Compress(Program.FileMgr.GetFileByte((int)cclient.Account.Id, FileId, true, "", ""));
     cclient.Send(Out);
     return 0;
 }
Exemplo n.º 29
0
        static public void F_TEXT(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (cclient.Plr == null)
                return;

            byte Unk = packet.GetUint8();
            string Text = packet.GetString((int)(packet.Length - packet.Position));

            CommandMgr.HandleText(cclient.Plr, Text);
        }
Exemplo n.º 30
0
        static public void F_SOCIAL_NETWORK(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (!cclient.IsPlaying() || !cclient.Plr.IsInWorld())
                return;

            Player Plr = cclient.Plr;

            byte Type = packet.GetUint8();

            switch (Type)
            {
                case 11: // Inspection
                    {
                        Player Target = Plr.CbtInterface.GetTarget(GameData.TargetTypes.TARGETTYPES_TARGET_ALLY) as Player;
                        if (Target == null)
                            Plr.SendLocalizeString("", GameData.Localized_text.TEXT_SN_LISTS_ERR_PLAYER_NOT_FOUND);
                        else
                            Target.ItmInterface.SendInspect(Plr);
                    }
                    break;
                case 8:
                    {
                        packet.Skip(1);
                        byte NameSize = packet.GetUint8();
                        packet.Skip(1);
                        string Name = packet.GetString(NameSize);
                        byte GuildSize = packet.GetUint8();
                        packet.Skip(1);
                        string GuildName = packet.GetString(GuildSize);
                        packet.Skip(1);
                        UInt16 Career = packet.GetUint16();
                        packet.Skip(4);
                        UInt16 ZoneId = packet.GetUint16();

                        while (ZoneId > 256)
                            ZoneId -= 256;

                        while (packet.GetUint8() != 0xFF) ;

                        packet.Skip(2 + (ZoneId == 255 ? 0 : 1));

                        byte MinLevel = packet.GetUint8();
                        byte MaxLevel = packet.GetUint8();

                        Plr.SocInterface.SendPlayers(Player.GetPlayers(Name, GuildName, Career, ZoneId, MinLevel, MaxLevel));

                    } break;

            }
        }
Exemplo n.º 31
0
        public async Task logCreatedNewAuth0Client(BaseClient requestingClient, string createdAuth0AccountEmail)
        {
            await repository.CreateNewLogEntry(makeLogTemplateObject(await getCategoryByName(LoggingConstants.CREATED_NEW_AUTH0_CLIENT_CATEGORY), $"{requestingClient.nickname} requested to make a client an Auth0 account for the email: {createdAuth0AccountEmail}"));

            await saveLogs();
        }
        public virtual async Task Validate(BaseClient client, CancellationToken cancellationToken)
        {
            var authGrantTypes         = _responseTypeHandlers.Select(r => r.GrantType);
            var supportedGrantTypes    = _grantTypeHandlers.Select(g => g.GrantType).Union(authGrantTypes).Distinct();
            var notSupportedGrantTypes = client.GrantTypes.Where(gt => !supportedGrantTypes.Any(sgt => sgt == gt));

            if (notSupportedGrantTypes.Any())
            {
                throw new OAuthException(ErrorCodes.INVALID_CLIENT_METADATA, string.Format(ErrorMessages.UNSUPPORTED_GRANT_TYPES, string.Join(",", notSupportedGrantTypes)));
            }

            if (!string.IsNullOrWhiteSpace(client.TokenEndPointAuthMethod) && !_oauthClientAuthenticationHandlers.Any(o => o.AuthMethod == client.TokenEndPointAuthMethod))
            {
                throw new OAuthException(ErrorCodes.INVALID_CLIENT_METADATA, string.Format(ErrorMessages.UNKNOWN_AUTH_METHOD, client.TokenEndPointAuthMethod));
            }

            var supportedResponseTypeHandlers = _responseTypeHandlers.Where(r => client.GrantTypes.Contains(r.GrantType));

            if (supportedResponseTypeHandlers.Any())
            {
                var supportedResponseTypes   = supportedResponseTypeHandlers.Select(s => s.ResponseType);
                var unSupportedResponseTypes = client.ResponseTypes.Where(r => !supportedResponseTypes.Contains(r));
                if (unSupportedResponseTypes.Any())
                {
                    throw new OAuthException(ErrorCodes.INVALID_CLIENT_METADATA, string.Format(ErrorMessages.BAD_RESPONSE_TYPES, string.Join(",", unSupportedResponseTypes)));
                }
            }

            foreach (var kvp in supportedResponseTypeHandlers.GroupBy(k => k.GrantType))
            {
                if (!kvp.Any(k => client.ResponseTypes.Contains(k.ResponseType)))
                {
                    throw new OAuthException(ErrorCodes.INVALID_CLIENT_METADATA, string.Format(ErrorMessages.MISSING_RESPONSE_TYPE, kvp.Key));
                }
            }

            if (supportedResponseTypeHandlers.Any())
            {
                if (client.RedirectionUrls == null || !client.RedirectionUrls.Any())
                {
                    throw new OAuthException(ErrorCodes.INVALID_CLIENT_METADATA, string.Format(ErrorMessages.MISSING_PARAMETER, OAuthClientParameters.RedirectUris));
                }

                foreach (var redirectUrl in client.RedirectionUrls)
                {
                    CheckRedirectUrl(client, redirectUrl);
                }
            }

            var scopes             = client.AllowedScopes.Select(_ => _.Name);
            var existingScopes     = (await _oauthScopeRepository.FindOAuthScopesByNames(scopes, cancellationToken));
            var existingScopeNames = existingScopes.Select(s => s.Name);
            var unsupportedScopes  = scopes.Except(existingScopeNames);

            if (unsupportedScopes.Any())
            {
                throw new OAuthException(ErrorCodes.INVALID_CLIENT_METADATA, string.Format(ErrorMessages.UNSUPPORTED_SCOPES, string.Join(",", unsupportedScopes)));
            }

            client.AllowedScopes = existingScopes;
            CheckUri(client.JwksUri, ErrorMessages.BAD_JWKS_URI);
            CheckUris(client.ClientUris, ErrorMessages.BAD_CLIENT_URI);
            CheckUris(client.LogoUris, ErrorMessages.BAD_LOGO_URI);
            CheckUris(client.TosUris, ErrorMessages.BAD_TOS_URI);
            CheckUris(client.PolicyUris, ErrorMessages.BAD_POLICY_URI);
            CheckSignature(client.TokenSignedResponseAlg, ErrorMessages.UNSUPPORTED_TOKEN_SIGNED_RESPONSE_ALG);
            CheckEncryption(client.TokenEncryptedResponseAlg, client.TokenEncryptedResponseEnc, ErrorMessages.UNSUPPORTED_TOKEN_ENCRYPTED_RESPONSE_ALG, ErrorMessages.UNSUPPORTED_TOKEN_ENCRYPTED_RESPONSE_ENC, OAuthClientParameters.TokenEncryptedResponseAlg);
            if (!string.IsNullOrWhiteSpace(client.JwksUri) && client.JsonWebKeys != null)
            {
                throw new OAuthException(ErrorCodes.INVALID_CLIENT_METADATA, ErrorMessages.DUPLICATE_JWKS);
            }
        }
Exemplo n.º 33
0
        public async Task logGetProfile(BaseClient requestingClient, Profile returnedProfile)
        {
            await repository.CreateNewLogEntry(makeLogTemplateObject(await getCategoryByName(LoggingConstants.GET_PROFILE_CATEGORY), requestingClient.nickname + " made a request to get a profile object for: " + returnedProfile.nickname));

            await saveLogs();
        }
Exemplo n.º 34
0
        public async Task logModifiedClientStatus(BaseClient requestingClient, Client affectedClientWithNewStatus, Status oldStatus)
        {
            await repository.CreateNewLogEntry(makeLogTemplateObject(await getCategoryByName(LoggingConstants.MODIFIED_CLIENT_STATUS_CATEGORY), $"{requestingClient.nickname} requested to modify {affectedClientWithNewStatus.nickname}'s status from '{oldStatus.statusDescription}' to '{affectedClientWithNewStatus.clientStatus.statusDescription}'"));

            await saveLogs();
        }
Exemplo n.º 35
0
        public async Task logDeletedClient(BaseClient requestingClient, BaseClient deletedClient)
        {
            await repository.CreateNewLogEntry(makeLogTemplateObject(await getCategoryByName(LoggingConstants.DELETED_CLIENT_CATEGORY), $"{requestingClient.nickname} requested to delete {deletedClient.nickname} and all related entities"));

            await saveLogs();
        }
Exemplo n.º 36
0
        public async Task logDeletedTag(BaseClient requestingClient, Logic.Objects.Tag deletedTag)
        {
            await repository.CreateNewLogEntry(makeLogTemplateObject(await getCategoryByName(LoggingConstants.DELETED_TAG_CATEGORY), $"{requestingClient.nickname} requested to delete the {deletedTag.tagName} tag"));

            await saveLogs();
        }
Exemplo n.º 37
0
        public async Task logError(BaseClient requestingClient, string category)
        {
            Category errorCategory = await getCategoryByName(LoggingConstants.MODIFIED_ANSWER_CATEGORY);

            string logMessage = $"{requestingClient.nickname}'s request failed. ";

            #region post
            if (errorCategory.categoryName == LoggingConstants.CREATED_ASSIGNMENT_CATEGORY)
            {
                logMessage += "There was an error posting new assignments";
            }
            if (errorCategory.categoryName == LoggingConstants.CREATED_NEW_MESSAGE_CATEGORY)
            {
                logMessage += "There was an error creating a new message";
            }

            if (errorCategory.categoryName == LoggingConstants.CREATED_NEW_CLIENT_CATEGORY)
            {
                logMessage += "There was an error creating a new client object";
            }
            if (errorCategory.categoryName == LoggingConstants.CREATED_NEW_AUTH0_CLIENT_CATEGORY)
            {
                logMessage += "There was an error creating a new Auth0 account for a client";
            }
            if (errorCategory.categoryName == LoggingConstants.CREATED_NEW_TAG_CATEGORY)
            {
                logMessage += "There was an error creating a new tag";
            }
            if (errorCategory.categoryName == LoggingConstants.CREATED_NEW_CLIENT_TAG_RELATIONSHIPS_CATEGORY)
            {
                logMessage += "There was an error adding a tag to a client";
            }
            #endregion

            #region get
            if (errorCategory.categoryName == LoggingConstants.GET_ALL_CLIENT_CATEGORY)
            {
                logMessage += "There was an error getting all clients";
            }
            if (errorCategory.categoryName == LoggingConstants.GET_PROFILE_CATEGORY)
            {
                logMessage += "There was an error retrieving a profile";
            }
            if (errorCategory.categoryName == LoggingConstants.GET_SPECIFIC_CLIENT_CATEGORY)
            {
                logMessage += "There was an error getting the client data";
            }
            if (errorCategory.categoryName == LoggingConstants.GET_SPECIFIC_HISTORY_CATEGORY)
            {
                logMessage += "There was an error getting the history object";
            }
            if (errorCategory.categoryName == LoggingConstants.GET_ALL_HISTORY_CATEGORY)
            {
                logMessage += "There was an error getting all of the history objects";
            }
            #endregion

            #region put
            if (errorCategory.categoryName == LoggingConstants.MODIFIED_ANSWER_CATEGORY)
            {
                logMessage += "There was an error changing the answer";
            }
            if (errorCategory.categoryName == LoggingConstants.MODIFIED_ASSIGNMENT_STATUS_CATEGORY)
            {
                logMessage += "There was an error modifying the assignment's status";
            }
            if (errorCategory.categoryName == LoggingConstants.MODIFIED_CLIENT_CATEGORY)
            {
                logMessage += "There was an error modifying a client";
            }
            if (errorCategory.categoryName == LoggingConstants.MODIFIED_PROFILE_CATEGORY)
            {
                logMessage += "There was an error modifying the profile";
            }
            if (errorCategory.categoryName == LoggingConstants.MODIFIED_MESSAGE_READ_STATUS_CATEGORY)
            {
                logMessage += "There was an error modifying the read status of a message";
            }
            if (errorCategory.categoryName == LoggingConstants.MODIFIED_CLIENT_STATUS_CATEGORY)
            {
                logMessage += "There was an error modifying a client's status";
            }
            #endregion

            #region delete
            if (errorCategory.categoryName == LoggingConstants.DELETED_CLIENT_CATEGORY)
            {
                logMessage += "There was an error deleting a client and all the related entities";
            }
            if (errorCategory.categoryName == LoggingConstants.DELETED_ASSIGNMENT_CATEGORY)
            {
                logMessage += "There was an error deleting an assignment from a client's list";
            }
            if (errorCategory.categoryName == LoggingConstants.DELETED_TAG_CATEGORY)
            {
                logMessage += "There was an error deleting a tag";
            }
            #endregion

            await repository.CreateNewLogEntry(makeLogTemplateObject(errorCategory, logMessage));
            await saveLogs();
        }
Exemplo n.º 38
0
        public async Task logCreatedNewTag(BaseClient requestingClient, Logic.Objects.Tag newTag)
        {
            await repository.CreateNewLogEntry(makeLogTemplateObject(await getCategoryByName(LoggingConstants.CREATED_NEW_TAG_CATEGORY), $"{requestingClient.nickname} requested to make a new tag: {newTag.tagName}"));

            await saveLogs();
        }
Exemplo n.º 39
0
 public Task <bool> Delete(BaseClient data, CancellationToken cancellationToken)
 {
     _clients.Remove(_clients.First(c => c.ClientId == data.ClientId));
     return(Task.FromResult(true));
 }
Exemplo n.º 40
0
        /// <summary>
        /// Inits the repo, gpg etc
        /// </summary>
        public frmMain()
        {
            InitializeComponent();

            var bugsnag = new BaseClient("23814316a6ecfe8ff344b6a467f07171");

            EnableTray = false;

            // Getting actual version
            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
            FileVersionInfo            fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);
            string version = fvi.FileVersion;

            cfg["version"] = version.Remove(5, 2);

            this.Text = "Pass4Win " + Strings.Version + " " + cfg["version"];

            // checking for update this an async operation
            LatestPass4WinRelease();

            // Do we have a valid password store and settings
            try
            {
                if (cfg["PassDirectory"] == "")
                {
                    // this will fail, I know ugly hack
                }
            }
            catch
            {
                cfg["FirstRun"] = true;
                frmConfig Config       = new frmConfig();
                var       dialogResult = Config.ShowDialog();
            }
            //checking git status
            if (!LibGit2Sharp.Repository.IsValid(cfg["PassDirectory"]))
            {
                // Remote or generate a new one
                if (cfg["UseGitRemote"] == true)
                {
                    // check if server is alive
                    if (IsGITAlive(cfg["UseGitRemote"]) || IsHTTPSAlive(cfg["UseGitRemote"]))
                    {
                        // clone the repo and catch any error
                        try
                        {
                            string clonedRepoPath = LibGit2Sharp.Repository.Clone(cfg["GitRemote"], cfg["PassDirectory"], new CloneOptions()
                            {
                                CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials
                                {
                                    Username = cfg["GitUser"],
                                    Password = DecryptConfig(cfg["GitPass"], "pass4win")
                                }
                            });
                        }
                        catch
                        {
                            MessageBox.Show(Strings.Error_connection, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            toolStripOffline.Visible = true;
                        }
                    }
                    else
                    {
                        MessageBox.Show(Strings.Error_git_unreachable, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        toolStripOffline.Visible = true;
                    }
                }
                else
                {
                    // creating new Git
                    var repo = LibGit2Sharp.Repository.Init(cfg["PassDirectory"], false);
                    toolStripOffline.Visible = true;
                }
            }
            else
            {
                // Do we do remote or not
                CheckOnline(true);
            }

            // Making sure core.autocrlf = true
            using (var repo = new LibGit2Sharp.Repository(cfg["PassDirectory"]))
            {
                repo.Config.Set("core.autocrlf", true);
            }

            // Init GPG if needed
            string gpgfile = cfg["PassDirectory"];

            gpgfile += "\\.gpg-id";
            // Check if we need to init the directory
            if (!File.Exists(gpgfile))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(gpgfile));
                KeySelect newKeySelect = new KeySelect();
                if (newKeySelect.ShowDialog() == DialogResult.OK)
                {
                    using (StreamWriter w = new StreamWriter(gpgfile))
                    {
                        w.Write(newKeySelect.gpgkey);
                    }
                    using (var repo = new LibGit2Sharp.Repository(cfg["PassDirectory"]))
                    {
                        repo.Stage(gpgfile);
                        repo.Commit("gpgid added", new LibGit2Sharp.Signature("pass4win", "pass4win", System.DateTimeOffset.Now), new LibGit2Sharp.Signature("pass4win", "pass4win", System.DateTimeOffset.Now));
                    }
                }
                else
                {
                    newKeySelect.Close();
                    MessageBox.Show(Strings.Error_nokey, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    System.Environment.Exit(1);
                }
            }
            // Setting the exe location for the GPG Dll
            GpgInterface.ExePath = cfg["GPGEXE"];

            // Setting up datagrid
            dt.Columns.Add("colPath", typeof(string));
            dt.Columns.Add("colText", typeof(string));

            treeDt.Columns.Add("colPath", typeof(string));
            treeDt.Columns.Add("colText", typeof(string));

            ListDirectory(new DirectoryInfo(cfg["PassDirectory"]), "");
            fillDirectoryTree(dirTreeView, cfg["PassDirectory"]);

            dataPass.DataSource         = dt.DefaultView;
            dataPass.Columns[0].Visible = false;

            EnableTray = true;
        }
Exemplo n.º 41
0
        static public void F_PLAYER_STATE2(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (cclient.Plr == null || !cclient.Plr.IsInWorld())
            {
                return;
            }

            Player Plr = cclient.Plr;

            long Pos = packet.Position;

            PacketOut Out = new PacketOut((byte)Opcodes.F_PLAYER_STATE2);

            Out.Write(packet.ToArray(), (int)packet.Position, (int)packet.Size);
            Out.WriteByte(0);
            Plr.DispatchPacket(Out, false);

            packet.Position = Pos;

            UInt16 Key = packet.GetUint16();

            byte Type         = packet.GetUint8();
            byte MoveingState = packet.GetUint8();
            byte CombatByte   = packet.GetUint8();
            byte Strafe       = packet.GetUint8();

            UInt16 Heading = packet.GetUint16R();
            UInt16 X       = packet.GetUint16R();
            UInt16 Y       = packet.GetUint16R();
            byte   Unk1    = packet.GetUint8();
            UInt16 Z       = packet.GetUint16R();
            byte   zmod    = packet.GetUint8();

            //Log.Success("zMod ",""+zmod);
            // zmod is somewhat strange what i found out so far
            // z mod is 255 while standing
            // z mod is 0 while running and z is below 65535
            // z mod is 1 while running and z is above 65535
            // z mod can be  113 / 97 / 115 / 99 while running and z is below 65535 and enemy in target
            // z mod is 99 / 100 / 116  while running and z is above 65535 and enemy in target

            // z mod is 4 while running in water
            // z mod is 68 while swimming in water
            // z mod is ticking with 255 7 times then 68 while standing in deep water
            // z mod is 12 while running in water (that should lower your health / kill you and reduce movement speed)
            // z mod is ticking with 255 7 times then 12 while standing in lava

            if (packet.Size < 10)
            {
                return;
            }

            int z_temp = Z;

            Heading /= 8;
            X       /= 2;
            Y       /= 2;

            // z update if z is higher then 65535
            if (zmod != 0 && zmod != 97 && zmod != 113 && zmod != 99 && zmod != 115)
            {
                z_temp += 65535;
            }

            if (Type != (byte)MovementTypes.NotMoving)
            {
                Plr.IsMoving = true;
            }
            else
            {
                Plr.IsMoving = false;
            }

            //Log.Success("Movement Before ", X + "," + Y + "," + Z);
            if (CombatByte >= 50 && CombatByte < 0x92 || CombatByte == 0xDF)
            {
                if (Plr.LastCX != 0 && Plr.LastCY != 0)
                {
                    if (Plr.LastCX > 12288 && X < 4096)
                    {
                        Plr.SetOffset((ushort)(Plr.XOffset + 1), Plr.YOffset);
                    }
                    else if (X > 12288 && Plr.LastCX < 4096)
                    {
                        Plr.SetOffset((ushort)(Plr.XOffset - 1), Plr.YOffset);
                    }

                    if (Plr.LastCY > 24576 && Y < 8192)
                    {
                        Plr.SetOffset(Plr.XOffset, (ushort)(Plr.YOffset + 1));
                    }
                    else if (Y > 24576 && Plr.LastCY < 8192)
                    {
                        Plr.SetOffset(Plr.XOffset, (ushort)(Plr.YOffset - 1));
                    }
                }

                Plr.LastCX = X;
                Plr.LastCY = Y;

                X = Plr.Zone.CalculCombat(X, Plr.XOffset, true);
                Y = Plr.Zone.CalculCombat(Y, Plr.YOffset, false);

                Heading /= 2;
                z_temp  /= 16;

                // combat offset z
                if (Plr._ZoneMgr.ZoneId == 161 || Plr._ZoneMgr.ZoneId == 162)
                {
                    z_temp += 12288;
                }
                else
                {
                    z_temp += 4096;
                }
            }
            else
            {
                if (Plr.LastX != 0 && Plr.LastY != 0)
                {
                    if (Plr.LastX > 24576 && X < 4096)
                    {
                        Plr.SetOffset((ushort)(Plr.XOffset + 1), Plr.YOffset);
                    }
                    else if (Plr.LastX < 4096 && X > 24576)
                    {
                        Plr.SetOffset((ushort)(Plr.XOffset - 1), Plr.YOffset);
                    }

                    if (Plr.LastY > 24576 && Y < 4096)
                    {
                        Plr.SetOffset(Plr.XOffset, (ushort)(Plr.YOffset + 1));
                    }
                    else if (Plr.LastY < 4096 && Y > 24576)
                    {
                        Plr.SetOffset(Plr.XOffset, (ushort)(Plr.YOffset - 1));
                    }
                }

                Plr.LastX = X;
                Plr.LastY = Y;

                X       = Plr.Zone.CalculPin(X, Plr.XOffset, true);
                Y       = Plr.Zone.CalculPin(Y, Plr.YOffset, false);
                z_temp /= 4;
            }

            //  if (Plr.IsInWorld() && Plr.Zone.ZoneId == 161)
            //      Z += 16384;

            //Log.Success("Movement after", "X=" + X + ",Y=" + Y + ",Z=" + Z + ",ztemp = " + z_temp + "," + Type + "," + Unk1 + "," + CombatByte);
            Plr.SetPosition(X, Y, (ushort)z_temp, Heading);
        }
 public SearchMembersClient(BaseClient baseClient)
 {
     _baseClient = baseClient;
 }
Exemplo n.º 43
0
 public static void F_UI_MOD(BaseClient client, PacketIn packet)
 {
     GameClient cclient = client as GameClient;
     //Log.Dump("F_UI_MOD", packet, true);
 }
Exemplo n.º 44
0
 public override void HandleMcpeDisconnect(McpeDisconnect message)
 {
     Log.Info($"Received disconnect: {message.message}");
     BaseClient.ShowDisconnect(message.message, false);
     base.HandleMcpeDisconnect(message);
 }
Exemplo n.º 45
0
        public async Task logCreatedNewClient(BaseClient requestingClient, Client newClient)
        {
            await repository.CreateNewLogEntry(makeLogTemplateObject(await getCategoryByName(LoggingConstants.CREATED_NEW_CLIENT_CATEGORY), $"{requestingClient.nickname} requested to make a new client object with email: {newClient.email}"));

            await saveLogs();
        }
Exemplo n.º 46
0
        public async Task logGetSpecificClient(BaseClient requestingClient, BaseClient requestedClient)
        {
            await repository.CreateNewLogEntry(makeLogTemplateObject(await getCategoryByName(LoggingConstants.GET_SPECIFIC_CLIENT_CATEGORY), requestingClient.nickname + " made a request to retrieve the client information for " + requestedClient.nickname));

            await saveLogs();
        }
Exemplo n.º 47
0
 public override void HandleMcpeAvailableCommands(McpeAvailableCommands message)
 {
     BaseClient.LoadCommands(message.CommandSet);
     //UnhandledPackage(message);
 }
        public async Task <List <MessageHistory> > GetAllChatHistories(BaseClient subjectClient)
        {
            List <Message.Data.Entities.Client> contextClients = await santaContext.Clients.Include(c => c.ClientStatus).Where(c => c.ClientStatus.StatusDescription != Constants.AWAITING_STATUS && c.ClientStatus.StatusDescription != Constants.DENIED_STATUS).ToListAsync();

            /* Assignment history query */

            /*
             * Xref is not null
             * Event type is the type of event attatched to the xref
             * Assignment status is attached to xref
             * Subject client is the meta passed in the method
             * Conversation client is the sender client (The agent)
             * Assignment sender is the sender client (The agent)
             * Assignment reciever client is the reciever client (The actual assignment client)
             *
             * Subject and reciever messages are new lists for loading times since histories are lazy loaded in the app
             *
             */
            List <MessageHistory> listLogicAssignmentMessageHistory = await santaContext.ClientRelationXrefs
                                                                      .Select(xref => new MessageHistory()
            {
                relationXrefID = xref.ClientRelationXrefId,
                eventType      = new Event()
                {
                    eventTypeID      = xref.EventType.EventTypeId,
                    eventDescription = xref.EventType.EventDescription,
                    active           = xref.EventType.IsActive,
                    removable        = xref.EventType.ClientRelationXrefs.Count == 0 && xref.EventType.Surveys.Count == 0,
                    immutable        = xref.EventType.EventDescription == Constants.CARD_EXCHANGE_EVENT || xref.EventType.EventDescription == Constants.GIFT_EXCHANGE_EVENT
                },
                assignmentStatus = Mapper.MapAssignmentStatus(xref.AssignmentStatus),

                subjectClient            = Mapper.MapClientChatMeta(subjectClient),
                conversationClient       = Mapper.MapClientChatMeta(xref.SenderClient),
                assignmentRecieverClient = Mapper.MapClientChatMeta(xref.RecipientClient),
                assignmentSenderClient   = Mapper.MapClientChatMeta(xref.SenderClient),

                subjectMessages  = new List <ChatMessage>(),
                recieverMessages = new List <ChatMessage>(),

                unreadCount = xref.ChatMessages
                              .Where(m => !m.FromAdmin && m.IsMessageRead == false)
                              .Count()
            }).ToListAsync();

            /* General history query */

            /*
             * All clients where the status of the client is approved or completed (Awaiting and denied have no chat history)
             *
             * Xref is null
             * Event type does not exist
             * Assignment status does not exist
             * Subject client is the meta passed in the method
             * Conversation client is the client object in the context
             * Assingment sender/reciever clients do not exist
             *
             * Subject and reciever messages are new lists for loading times since histories are lazy loaded in the app
             */
            List <MessageHistory> logicGeneralChatHistories = await santaContext.Clients.Where(c => c.ClientStatus.StatusDescription == Constants.APPROVED_STATUS || c.ClientStatus.StatusDescription == Constants.COMPLETED_STATUS)
                                                              .Select(client => new MessageHistory()
            {
                relationXrefID   = null,
                eventType        = new Event(),
                assignmentStatus = new AssignmentStatus(),

                subjectClient            = Mapper.MapClientChatMeta(subjectClient),
                conversationClient       = Mapper.MapClientChatMeta(client),
                assignmentRecieverClient = new ClientChatMeta(),
                assignmentSenderClient   = new ClientChatMeta(),

                subjectMessages  = new List <ChatMessage>(),
                recieverMessages = new List <ChatMessage>(),

                unreadCount = client.ChatMessageMessageSenderClients
                              .Where(m => m.ClientRelationXrefId == null && !m.MessageSenderClient.IsAdmin && m.IsMessageRead == false)
                              .Count()
            }).ToListAsync();

            List <MessageHistory> totalHistories = listLogicAssignmentMessageHistory.Concat(logicGeneralChatHistories).ToList();


            return(totalHistories.OrderByDescending(h => h.eventType.eventDescription).ThenBy(h => h.conversationClient.clientNickname).ToList());
        }
Exemplo n.º 49
0
        public async Task logDeletedAssignment(BaseClient requestingClient, BaseClient affectedClient, RelationshipMeta deletedAssignment)
        {
            await repository.CreateNewLogEntry(makeLogTemplateObject(await getCategoryByName(LoggingConstants.DELETED_ASSIGNMENT_CATEGORY), $"{requestingClient.nickname} requested to remove {deletedAssignment.relationshipClient.clientNickname} from {affectedClient.nickname}'s assignment list"));

            await saveLogs();
        }
Exemplo n.º 50
0
        public async Task PostAsyncReturnsBatchResponseContent()
        {
            using (HttpResponseMessage responseMessage = new HttpResponseMessage(HttpStatusCode.OK))
                using (TestHttpMessageHandler testHttpMessageHandler = new TestHttpMessageHandler())
                {
                    /* Arrange */
                    // 1. create a mock response
                    string requestUrl   = "https://localhost/";
                    string responseJSON = "{\"responses\":"
                                          + "[{"
                                          + "\"id\": \"1\","
                                          + "\"status\":200,"
                                          + "\"headers\":{\"Cache-Control\":\"no-cache\",\"OData-Version\":\"4.0\",\"Content-Type\":\"application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8\"},"
                                          + "\"body\":{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#users/$entity\",\"displayName\":\"MOD Administrator\",\"jobTitle\":null,\"id\":\"9f4fe8ea-7e6e-486e-b8f4-VkHdanfIomf\"}"
                                          + "},"
                                          + "{"
                                          + "\"id\": \"2\","
                                          + "\"status\":409,"
                                          + "\"headers\" : {\"Cache-Control\":\"no-cache\"},"
                                          + "\"body\":{\"error\": {\"code\": \"20117\",\"message\": \"An item with this name already exists in this location.\",\"innerError\":{\"request-id\": \"nothing1b13-45cd-new-92be873c5781\",\"date\": \"2019-03-22T23:17:50\"}}}"
                                          + "}]}";
                    HttpContent content = new StringContent(responseJSON);
                    responseMessage.Content = content;

                    // 2. Map the response
                    testHttpMessageHandler.AddResponseMapping(requestUrl, responseMessage);

                    // 3. Create a batch request object to be tested
                    MockCustomHttpProvider customHttpProvider = new MockCustomHttpProvider(testHttpMessageHandler);
                    BaseClient             client             = new BaseClient(requestUrl, authenticationProvider.Object, customHttpProvider);
                    BatchRequest           batchRequest       = new BatchRequest(requestUrl, client);

                    // 4. Create batch request content to be sent out
                    // 4.1 Create HttpRequestMessages for the content
                    HttpRequestMessage httpRequestMessage1 = new HttpRequestMessage(HttpMethod.Get, "https://graph.microsoft.com/v1.0/me/");
                    HttpRequestMessage httpRequestMessage2 = new HttpRequestMessage(HttpMethod.Post, "https://graph.microsoft.com/v1.0/me/onenote/notebooks");

                    // 4.2 Create batch request steps with request ids.
                    BatchRequestStep requestStep1 = new BatchRequestStep("1", httpRequestMessage1);
                    BatchRequestStep requestStep2 = new BatchRequestStep("2", httpRequestMessage2, new List <string> {
                        "1"
                    });

                    // 4.3 Add batch request steps to BatchRequestContent.
                    BatchRequestContent batchRequestContent = new BatchRequestContent(requestStep1, requestStep2);

                    /* Act */
                    BatchResponseContent returnedResponse = await batchRequest.PostAsync(batchRequestContent);

                    HttpResponseMessage firstResponse = await returnedResponse.GetResponseByIdAsync("1");

                    HttpResponseMessage secondResponse = await returnedResponse.GetResponseByIdAsync("2");

                    /* Assert */
                    // validate the first response
                    Assert.NotNull(firstResponse);
                    Assert.Equal(HttpStatusCode.OK, firstResponse.StatusCode);
                    Assert.True(firstResponse.Headers.CacheControl.NoCache);
                    Assert.NotNull(firstResponse.Content);

                    // validate the second response
                    Assert.NotNull(secondResponse);
                    Assert.Equal(HttpStatusCode.Conflict, secondResponse.StatusCode);
                    Assert.True(secondResponse.Headers.CacheControl.NoCache);
                    Assert.NotNull(secondResponse.Content);
                }
        }
Exemplo n.º 51
0
 public override void HandleMcpeRequestChunkRadius(McpeRequestChunkRadius message)
 {
     BaseClient.RequestChunkRadius(Client.ChunkRadius);
 }
Exemplo n.º 52
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     SendDistrictEnter((WorldClient)client);
     return(0);
 }
Exemplo n.º 53
0
        public async Task logModifiedClient(BaseClient requestingClient, Client modifiedClient)
        {
            await repository.CreateNewLogEntry(makeLogTemplateObject(await getCategoryByName(LoggingConstants.GET_ALL_HISTORY_CATEGORY), $"{requestingClient.nickname} modified a client's data for {modifiedClient.nickname}"));

            await saveLogs();
        }
Exemplo n.º 54
0
        protected virtual T Get(string id, Dictionary <string, object> urlParams = null)
        {
            var result = BaseClient.Get(this.GetResourceUri(id) + Utils.BuildUrlParams(urlParams));

            return(Utils.Deserialize <T>(result));
        }
Exemplo n.º 55
0
        public static void F_COMMAND_CONTROLLED(BaseClient client, PacketIn packet)
        {
            GameClient cclient = (GameClient)client;

            if (cclient.Plr?.CrrInterface == null)
            {
                return;
            }

            IPetCareerInterface petInterface = cclient.Plr.CrrInterface as IPetCareerInterface;

            Pet myPet = petInterface?.myPet;

            if (myPet == null)
            {
                return;
            }

            ushort     abilityid = packet.GetUint16();
            PetCommand command   = (PetCommand)packet.GetUint8();

            switch (command)
            {
            case PetCommand.Stay:
                if (cclient.Plr.IsMounted)
                {
                    return;
                }
                myPet.MvtInterface.StopMove();
                myPet.FollowMode = 1;
                myPet.IsHeeling  = false;
                myPet.AiInterface.Debugger?.SendClientMessage("[MR]: Holding position by request.");
                myPet.SendPetUpdate();
                break;     // stay

            case PetCommand.Follow:
                if (cclient.Plr.IsMounted)
                {
                    return;
                }
                myPet.AiInterface.ProcessCombatEnd();
                if (myPet.StsInterface.Speed == 0)
                {
                    break;
                }
                myPet.MvtInterface.ScaleSpeed(myPet.SpeedMult);
                myPet.MvtInterface.Recall(cclient.Plr);
                myPet.FollowMode = 2;
                myPet.AiInterface.Debugger?.SendClientMessage("[MR]: Heeling by request.");
                myPet.SendPetUpdate();
                break;     // heel

            case PetCommand.Passive:
                myPet.AiInterface.SetBrain(new PassiveBrain(myPet));
                petInterface.AIMode = 3;
                myPet.AIMode        = 3;
                myPet.AiInterface.Debugger?.SendClientMessage("[MR]: Passive state.");
                break;     // mode Passive

            case PetCommand.Defensive:
                myPet.AiInterface.SetBrain(new GuardBrain(myPet));
                petInterface.AIMode = 4;
                myPet.AIMode        = 4;
                myPet.AiInterface.Debugger?.SendClientMessage("[MR]: Defensive state.");
                break;     // mode Defensive

            case PetCommand.Aggressive:
                myPet.AiInterface.SetBrain(new AggressiveBrain(myPet));
                petInterface.AIMode = 5;
                myPet.AIMode        = 5;
                myPet.AiInterface.Debugger?.SendClientMessage("[MR]: Aggressive state.");
                break;     // mode Aggressive

            case PetCommand.Attack:
                long now = TCPManager.GetTimeStampMS();
                if (cclient.Plr.IsMounted || now <= myPet.AttackReuseTimer + COMMAND_ATTACK_REUSE)
                {
                    return;
                }
                myPet.AttackReuseTimer = now;
                Unit target = cclient.Plr.CbtInterface.GetTarget(TargetTypes.TARGETTYPES_TARGET_ENEMY);
                if (target == null || !CombatInterface.CanAttack(myPet, target))
                {
                    return;
                }

                if (!cclient.Plr.LOSHit(target))
                {
                    return;
                }

                myPet.AiInterface.Debugger?.SendClientMessage("[MR]: Attacking by request.");
                myPet.IsHeeling  = false;
                myPet.FollowMode = 0;
                myPet.Owner.CbtInterface.RefreshCombatTimer();
                myPet.AiInterface.ProcessCombatStart(target);
                myPet.SendPetUpdate();
                break;     //attack

            case PetCommand.Release:
                myPet.Destroy();
                break;

            case PetCommand.AbilityCast:
                if (cclient.Plr.IsMounted)
                {
                    return;
                }
                foreach (NPCAbility pa in myPet.AbtInterface.NPCAbilities)
                {
                    if (pa.Entry == abilityid)
                    {
                        if (pa.Range > 0)
                        {
                            Unit abTarget = myPet.CbtInterface.GetCurrentTarget();
                            if (abTarget == null || !myPet.LOSHit(abTarget))
                            {
                                return;
                            }
                        }
                        myPet.AbtInterface.StartCast(myPet, abilityid, 1);
                        break;
                    }
                }
                break;

            case PetCommand.Autocast:
                if (cclient.Plr.IsMounted)
                {
                    return;
                }
                foreach (NPCAbility pa in myPet.AbtInterface.NPCAbilities)
                {
                    if (pa.Entry != abilityid)
                    {
                        continue;
                    }

                    pa.AutoUse = !pa.AutoUse;
                    myPet.SendPetUpdate();
                    break;
                }
                break;
            }
        }
Exemplo n.º 56
0
        public async Task logCreatedNewClientTagRelationships(BaseClient requestingClient, BaseClient targetClient)
        {
            await repository.CreateNewLogEntry(makeLogTemplateObject(await getCategoryByName(LoggingConstants.CREATED_NEW_CLIENT_TAG_RELATIONSHIPS_CATEGORY), $"{requestingClient.nickname} requested to add tags to {targetClient.nickname}"));

            await saveLogs();
        }
        public async Task <MessageHistory> GetChatHistoryByXrefIDAndSubjectIDAsync(Guid clientRelationXrefID, BaseClient subjectClient)
        {
            MessageHistory logicHistory = new MessageHistory();

            Message.Data.Entities.ClientRelationXref contextRelationship = await santaContext.ClientRelationXrefs
                                                                           .Include(r => r.EventType)
                                                                           .Include(r => r.SenderClient)
                                                                           .Include(r => r.RecipientClient)
                                                                           .Include(r => r.AssignmentStatus)
                                                                           .Include(r => r.ChatMessages)
                                                                           .ThenInclude(cm => cm.MessageReceiverClient)
                                                                           .Include(r => r.ChatMessages)
                                                                           .ThenInclude(cm => cm.MessageSenderClient)
                                                                           .Where(x => x.ClientRelationXrefId == clientRelationXrefID)
                                                                           .AsNoTracking()
                                                                           .FirstOrDefaultAsync();

            return(Mapper.MapHistoryInformation(contextRelationship, subjectClient, false));
        }
        public async Task <MessageHistory> GetGeneralChatHistoryBySubjectIDAsync(Client conversationClient, BaseClient subjectClient)
        {
            MessageHistory logicHistory = new MessageHistory();
            List <Message.Data.Entities.ChatMessage> contextListMessages = await santaContext.ChatMessages
                                                                           .Where(m => m.ClientRelationXrefId == null && (m.MessageSenderClientId == conversationClient.clientID || m.MessageReceiverClientId == conversationClient.clientID))
                                                                           .Include(s => s.MessageSenderClient)
                                                                           .Include(r => r.MessageReceiverClient)
                                                                           .AsNoTracking()
                                                                           .OrderBy(dt => dt.DateTimeSent)
                                                                           .ToListAsync();

            return(Mapper.MapHistoryInformation(conversationClient, contextListMessages, subjectClient));
        }
Exemplo n.º 59
0
        public async Task logGetAllClients(BaseClient requestingClient)
        {
            await repository.CreateNewLogEntry(makeLogTemplateObject(await getCategoryByName(LoggingConstants.GET_ALL_CLIENT_CATEGORY), requestingClient.nickname + " made a request to retrieve a list of all clients"));

            await saveLogs();
        }
        public void KickClient(string command, string[] args)
        {
            if (args.Length <= 0)
            {
                IGConsole.Instance.println("Usage: type \"help\"", false);
                return;
            }

            if (ulong.TryParse(args[0], out ulong Id))
            {
                if (socketObj.ConnectedClients.ContainsKey(Id))
                {
                    socketObj.ConnectedClients[Id].SendPacket(new ConnectionPacket(false, 0, false, false));
                    socketObj.ConnectedClients[Id].RootDispose();
                }
                else
                {
                    IGConsole.Instance.println("invalid ID", false);
                }
            }
            else
            {
                switch (args[0])
                {
                case "all":
                    foreach (var item in socketObj.ConnectedClients)
                    {
                        item.Value.SendPacket(new ConnectionPacket(false, 0, false, false));
                        item.Value.RootDispose();
                    }
                    break;

                case "index":
                    if (args.Length <= 1)
                    {
                        IGConsole.Instance.println("Usage: type \"help\"", false);
                        return;
                    }

                    if (int.TryParse(args[1], out int index))
                    {
                        int        i          = 0;
                        BaseClient baseClient = null;

                        foreach (var item in socketObj.ConnectedClients)
                        {
                            if (i == index)
                            {
                                baseClient = item.Value;
                            }
                            i++;
                        }
                        if (baseClient != null)
                        {
                            baseClient.SendPacket(new ConnectionPacket(false, 0, false, false));
                            baseClient.RootDispose();
                        }
                        else
                        {
                            IGConsole.Instance.println("invalid index", false);
                        }
                    }
                    else
                    {
                        IGConsole.Instance.println("invalid parameter", false);
                    }
                    break;

                default:
                    IGConsole.Instance.println("invalid parameter", false);
                    break;
                }
            }
        }