public void Revoke(LogNetClient client, bnet.protocol.channel_invitation.RevokeInvitationRequest request) { if (!this._onGoingInvitations.ContainsKey(request.InvitationId)) { return; } var invitation = this._onGoingInvitations[request.InvitationId]; var channel = ChannelManager.GetChannelByEntityId(request.ChannelId); //notify inviter about revoke var updateChannelNotification = bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder() .SetAgentId(bnet.protocol.EntityId.CreateBuilder().SetHigh(0).SetLow(0)) // caps have this set to high: 0 low: 0 /dustin .SetStateChange(bnet.protocol.channel.ChannelState.CreateBuilder() .AddInvitation(invitation) .SetReason((uint)InvitationRemoveReason.Revoked)); this._onGoingInvitations.Remove(request.InvitationId); client.MakeTargetedRPC(channel, () => bnet.protocol.channel.ChannelSubscriber.CreateStub(client).NotifyUpdateChannelState(null, updateChannelNotification.Build(), callback => { })); //notify invitee about revoke var invitationRemoved = bnet.protocol.channel_invitation.InvitationRemovedNotification.CreateBuilder() .SetInvitation(invitation) .SetReason((uint)InvitationRemoveReason.Revoked); var invitee = GameAccountManager.GetAccountByPersistentID(invitation.InviteeIdentity.AccountId.Low); invitee.LoggedInClient.MakeTargetedRPC(this, () => bnet.protocol.channel_invitation.ChannelInvitationNotify.CreateStub(invitee.LoggedInClient).NotifyReceivedInvitationRemoved(null, invitationRemoved.Build(), callback => { })); }
public Channel HandleAccept(LogNetClient client, bnet.protocol.channel_invitation.AcceptInvitationRequest request) { if (!this._onGoingInvitations.ContainsKey(request.InvitationId)) { return(null); } var invitation = this._onGoingInvitations[request.InvitationId]; var channel = ChannelManager.GetChannelByEntityId(invitation.GetExtension(bnet.protocol.channel_invitation.ChannelInvitation.ChannelInvitationProp).ChannelDescription.ChannelId); var notification = bnet.protocol.channel_invitation.InvitationRemovedNotification.CreateBuilder().SetInvitation(invitation.ToBuilder()).SetReason((uint)InvitationRemoveReason.Accepted); this._onGoingInvitations.Remove(invitation.Id); // notify invitee and let him remove the handled invitation. client.MakeTargetedRPC(this, () => bnet.protocol.channel_invitation.ChannelInvitationNotify.CreateStub(client).NotifyReceivedInvitationRemoved(null, notification.Build(), callback => { })); channel.Join(client, request.ObjectId); // add invitee to channel -- so inviter and other members will also be notified too. var inviter = GameAccountManager.GetAccountByPersistentID(invitation.InviterIdentity.AccountId.Low); var stateNotification = bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder() .SetAgentId(bnet.protocol.EntityId.CreateBuilder().SetHigh(0).SetLow(0).Build()) .SetStateChange(bnet.protocol.channel.ChannelState.CreateBuilder().AddRangeInvitation(channel.Invitations.Values).SetReason(0).Build()) .Build(); foreach (var member in channel.Members.Keys) { member.MakeTargetedRPC(channel, () => bnet.protocol.channel.ChannelSubscriber.CreateStub(member).NotifyUpdateChannelState(null, stateNotification, callback => { })); } return(channel); }
public void HandleDecline(LogNetClient client, bnet.protocol.invitation.GenericRequest request) { if (!this._onGoingInvitations.ContainsKey(request.InvitationId)) { return; } var invitation = this._onGoingInvitations[request.InvitationId]; var inviter = GameAccountManager.GetAccountByPersistentID(invitation.InviterIdentity.AccountId.Low); if (inviter == null || inviter.LoggedInClient == null) { return; } var notification = bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder() .SetAgentId(bnet.protocol.EntityId.CreateBuilder().SetHigh(0).SetLow(0)) // caps have this set to high: 0 low: 0 /raist. .SetStateChange(bnet.protocol.channel.ChannelState.CreateBuilder().AddInvitation(invitation) .SetReason((uint)InvitationRemoveReason.Declined)); this._onGoingInvitations.Remove(invitation.Id); // notify invoker about the decline. inviter.LoggedInClient.MakeTargetedRPC(inviter.LoggedInClient.PartyChannel, () => bnet.protocol.channel.ChannelSubscriber.CreateStub(inviter.LoggedInClient).NotifyUpdateChannelState(null, notification.Build(), callback => { })); //inviter.LoggedInClient.MakeTargetedRPC(inviter.LoggedInClient.CurrentChannel, () => // bnet.protocol.channel.ChannelSubscriber.CreateStub(inviter.LoggedInClient).NotifyUpdateChannelState(null, notification.Build(), callback => { })); }
public string Search(string[] @params, LogNetClient invokerClient) { if (@params == null) { return(this.Fallback()); } var matches = new List <Asset>(); if (@params.Count() < 1) { return("Invalid arguments. Type 'help lookup actor' to get help."); } var pattern = @params[0].ToLower(); foreach (var groupPair in MPQStorage.Data.Assets) { foreach (var pair in groupPair.Value) { if (pair.Value.Name.ToLower().Contains(pattern)) { matches.Add(pair.Value); } } } return(matches.Aggregate(matches.Count >= 1 ? "Matches:\n" : "No matches found.", (current, match) => current + string.Format("[{0}] [{1}] {2}\n", match.SNOId.ToString("D6"), match.Group, match.Name))); }
public virtual string Handle(string parameters, LogNetClient invokerClient = null) { // check if the user has enough privileges to access command group. // check if the user has enough privileges to invoke the command. if (invokerClient != null && this.Attributes.MinUserLevel > invokerClient.Account.UserLevel) { return("You don't have enough privileges to invoke that command."); } string[] @params = null; CommandAttribute target = null; if (parameters == string.Empty) { target = this.GetDefaultSubcommand(); } else { @params = parameters.Split(' '); target = this.GetSubcommand(@params[0]) ?? this.GetDefaultSubcommand(); if (target != this.GetDefaultSubcommand()) { @params = @params.Skip(1).ToArray(); } } // check if the user has enough privileges to invoke the command. if (invokerClient != null && target.MinUserLevel > invokerClient.Account.UserLevel) { return("You don't have enough privileges to invoke that command."); } return((string)this._commands[target].Invoke(this, new object[] { @params, invokerClient })); }
/// <summary> /// Adds a client subscriber to object, which will eventually be notified whenever the object changes state. /// </summary> /// <param name="client">The client to add as a subscriber.</param> /// <param name="remoteObjectId">The client's dynamic ID.</param> public void AddSubscriber(LogNetClient client, ulong remoteObjectId) { // [D3Inferno] // Remove Subscribers that have been disconnected. // Apparently the RPCObject is not being cleaned up properly. // See the comment at the top for more info. // Conver to an Array so we can remove as we iterate. foreach (var subscriber in this.Subscribers.ToArray()) { if (!subscriber.Connection.IsConnected) { Logger.Warn("Removing disconnected subscriber {0}", subscriber); this.Subscribers.Remove(subscriber); } } // Map the subscriber's dynamic ID to to our dynamic ID so we know how to translate later on when the object makes a notify call client.MapLocalObjectID(this.DynamicId, remoteObjectId); this.Subscribers.Add(client); // Since the client wasn't previously subscribed, it should not be aware of the object's state -- let's notify it foreach (var subscriber in this.Subscribers) { this.NotifySubscriptionAdded(subscriber); } //this.NotifySubscriptionAdded(client); }
public string Item(string[] @params, LogNetClient invokerClient) { var matches = new List <ItemTable>(); if (@params.Count() < 1) { return("Invalid arguments. Type 'help lookup item' to get help."); } var pattern = @params[0].ToLower(); foreach (var asset in MPQStorage.Data.Assets[SNOGroup.GameBalance].Values) { var data = asset.Data as GameBalance; if (data == null || data.Type != BalanceType.Items) { continue; } foreach (var itemDefinition in data.Item) { if (itemDefinition.Name.ToLower().Contains(pattern)) { matches.Add(itemDefinition); } } } return(matches.Aggregate(matches.Count >= 1 ? "Item Matches:\n" : "No match found.", (current, match) => current + string.Format("[{0}] {1}\n", match.SNOActor.ToString("D6"), match.Name))); }
public string ChangeGender(string[] @params, LogNetClient invokerClient) { if (invokerClient == null) { return("You can not invoke this command from console."); } if (invokerClient.InGameClient == null) { return("You can only invoke this command while ingame."); } Toon toon = invokerClient.Account.CurrentGameAccount.CurrentToon; ToonFlags gender = invokerClient.Account.CurrentGameAccount.CurrentToon.Flags; var dbToon = DBSessions.AccountSession.Get <DBToon>(toon.PersistentID); string lastGender = toon.DBToon.Flags.ToString(); if (gender == ToonFlags.Male) { toon.DBToon.Flags = ToonFlags.Female; } else if (gender == ToonFlags.Female) { toon.DBToon.Flags = ToonFlags.Male; } DBSessions.AccountSession.SaveOrUpdate(dbToon); DBSessions.AccountSession.Flush(); return(string.Format("Gender {0} changed to {1}!. Reload to see the change.", lastGender, toon.DBToon.Flags.ToString())); }
public string Delete(string[] @params, LogNetClient invokerClient) { if (@params.Count() == 0) { return("Invalid arguments. Type 'help account delete' to get help."); } var account = AccountManager.GetAccountByEmail(@params[0]); if (account == null) { return(string.Format("No account with email '{0}' exists.", @params)); } //Delete game accounts for account //which in turn will delete toons for each game account foreach (var gameAccount in GameAccountManager.GetGameAccountsForAccount(account)) { GameAccountManager.DeleteGameAccount(gameAccount); } AccountManager.DeleteAccount(account); return(string.Format("Deleted account {0}.", @params)); }
public static void HandleRemove(LogNetClient client, bnet.protocol.friends.GenericFriendRequest request) { var removee = AccountManager.GetAccountByPersistentID(request.TargetId.Low); var remover = client.Account; var removeeAsFriend = bnet.protocol.friends.Friend.CreateBuilder().SetId(removee.BnetEntityId).Build(); var removerAsFriend = bnet.protocol.friends.Friend.CreateBuilder().SetId(remover.BnetEntityId).Build(); RemoveFriendshipFromDB(remover, removee); var notifyRemover = bnet.protocol.friends.FriendNotification.CreateBuilder().SetTarget(removeeAsFriend).Build(); client.MakeTargetedRPC(FriendManager.Instance, () => bnet.protocol.friends.FriendsNotify.CreateStub(client).NotifyFriendRemoved(null, notifyRemover, callback => { })); var removeeGameAccounts = GameAccountManager.GetGameAccountsForAccount(removee); foreach (var removeeGameAccount in removeeGameAccounts) { if (!removeeGameAccount.IsOnline) { continue; } var notifyRemovee = bnet.protocol.friends.FriendNotification.CreateBuilder().SetTarget(removerAsFriend).Build(); removeeGameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, () => bnet.protocol.friends.FriendsNotify.CreateStub(removeeGameAccount.LoggedInClient).NotifyFriendRemoved(null, notifyRemovee, callback => { })); } }
public static void HandleInvitation(LogNetClient client, bnet.protocol.invitation.Invitation invitation) { var invitee = AccountManager.GetAccountByPersistentID(invitation.InviteeIdentity.AccountId.Low); //var invitee = Instance.Subscribers.FirstOrDefault(subscriber => subscriber.Account.BnetEntityId.Low == invitation.InviteeIdentity.AccountId.Low); if (invitee == null) { return; // if we can't find invite just return - though we should actually check for it until expiration time and store this in database. } //Check for duplicate invites if (OnGoingInvitations.Values.Any(oldInvite => (oldInvite.InviteeIdentity.AccountId == invitation.InviteeIdentity.AccountId) && (oldInvite.InviterIdentity.AccountId == invitation.InviterIdentity.AccountId))) { return; } OnGoingInvitations.Add(invitation.Id, invitation); // track ongoing invitations so we can tranport it forth and back. if (invitee.IsOnline) { var inviter = AccountManager.GetAccountByPersistentID(invitation.InviterIdentity.AccountId.Low); var notification = bnet.protocol.friends.InvitationNotification.CreateBuilder().SetInvitation(invitation).SetGameAccountId(inviter.CurrentGameAccount.BnetEntityId); invitee.CurrentGameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, () => bnet.protocol.friends.FriendsNotify.CreateStub(invitee.CurrentGameAccount.LoggedInClient).NotifyReceivedInvitationAdded(null, notification.Build(), callback => { })); } }
protected void MakeRPC(LogNetClient client, List <bnet.protocol.presence.FieldOperation> operations) { // Create a presence.ChannelState var state = bnet.protocol.presence.ChannelState.CreateBuilder().SetEntityId(this.BnetEntityId).AddRangeFieldOperation(operations).Build(); // Embed in channel.ChannelState var channelState = bnet.protocol.channel.ChannelState.CreateBuilder().SetExtension(bnet.protocol.presence.ChannelState.Presence, state); // Put in AddNotification message var builder = bnet.protocol.channel.AddNotification.CreateBuilder().SetChannelState(channelState); // Make the RPC call to all online game accounts //TODO: Split notifications per game type client.MakeTargetedRPC(this, () => bnet.protocol.channel.ChannelSubscriber.CreateStub(client).NotifyAdd(null, builder.Build(), callback => { })); //foreach (var gameClient in client.Account.GameAccounts) //{ // if (gameClient.Value.IsOnline) // { // gameClient.Value.LoggedInClient.MakeTargetedRPC(this, () => // bnet.protocol.channel.ChannelSubscriber.CreateStub(gameClient.Value.LoggedInClient).NotifyAdd(null, builder.Build(), callback => { })); // } //} }
public string SetPassword(string[] @params, LogNetClient invokerClient) { if (@params.Count() < 2) { return("Invalid arguments. Type 'help account setpassword' to get help."); } var email = @params[0]; var password = @params[1]; var account = AccountManager.GetAccountByEmail(email); if (account == null) { return(string.Format("No account with email '{0}' exists.", email)); } if (password.Length < 8 || password.Length > 16) { return("Password should be a minimum of 8 and a maximum of 16 characters."); } AccountManager.UpdatePassword(account, password); return(string.Format("Updated password for account {0}.", email)); }
private static void InitAuthentication(LogNetClient client, bnet.protocol.authentication.LogonRequest request) { client.LoginEmail = request.Email; var account = AccountManager.GetAccountByEmail(request.Email.ToLower()); // check if account exists. if (account == null) // we should be returning an error to client /raist. { client.AuthenticationErrorCode = AuthenticationErrorCodes.NoGameAccount; client.AuthenticationComplete(); return; } var thumbprintData = "f9513183031b3836103ac3a3bb606c0e06fd3b94ae4a6b6e405844085b794e901b0ebb1db650b85bac4b489a38a1ca9dcef2bbd13445d0cd85accfc62d84bc3a8d960b1a7a65cd8d3f72a172f41dca98459015ffbd25d766b02824a42dacb7c4cd64f4b3b9e316de23ec1dbb0153b73a4fa58ffb39c3f484b4b478a660dc8979e16e52f978a0ca2fc4184fa0f69844d73ef99f47e3ccb02cf6a636b4ae9513404eee7e0ad536dcef50cd1699e38195e6afdd3655a3a3529b4e52b33ac5d04f5fa2b15536a2c782c89c0acf133e14eac15af035abf5e44e9e1124a3397dac8f90a4ccb1717540698869fc1ba9037e099d68698ecf17ffdd36f07013176be24269fda1e5d221708181d95474fc1d74bb901062a9f6a3e24aef79e9d583d9126796d63c153a0f75f02da27ecc0971f39a46ec29087c3ae474e08fdf8f65d1445b293399bc495ff651b7d2d7a36216ba5e4400ea7bbc884dc4cf3ed27f14501b8bb7fc0f86b5089880e6889bcd851153e299a337d6c945f710559595e351995341cbef44abac379cf0f845b362d294eec390d50f1a50089d250eae1b1205cea1aff514de076516f467cd077a1fbb759b415dc6c0ea1617f31f7d764a0d60d5b67aa82b4202b2a9455eb9ca3683955ec45aaf56aba42a2f3ae9be5f3eed093a6601816d00e0569bfcb91fb7843945336c99757812d373d510d25744f9480b6cc87e8a".ToByteArray(); var srp6a = new SRP6a(account); // create srp6 handler to process the authentication. OngoingAuthentications.Add(client, srp6a); // request client to load thumbprint.dll for authentication. var moduleLoadRequest = bnet.protocol.authentication.ModuleLoadRequest.CreateBuilder() .SetModuleHandle(bnet.protocol.ContentHandle.CreateBuilder() .SetRegion(VersionInfo.LogNet.Regions[VersionInfo.LogNet.Region]) .SetUsage(0x61757468) // auth - thumbprint.dll .SetHash(ByteString.CopyFrom(VersionInfo.LogNet.ThumbprintHashMap[client.Platform]))) .SetMessage(ByteString.CopyFrom(thumbprintData)) .Build(); client.LastRequestedModule = LogNetClient.StreamedModule.Thumbprint; client.MakeRPC(() => bnet.protocol.authentication.AuthenticationClient.CreateStub(client).ModuleLoad(null, moduleLoadRequest, callback => { })); }
public static Channel CreateNewChannel(LogNetClient client, ulong remoteObjectId) { var channel = new Channel(client, false, remoteObjectId); Channels.Add(channel.DynamicId, channel); return(channel); }
public string DropAll(string[] @params, LogNetClient invokerClient) { if (invokerClient == null) { return("You can not invoke this command from console."); } if (invokerClient.InGameClient == null) { return("You can only invoke this command while ingame."); } var player = invokerClient.InGameClient.Player; var bpItems = new List <Item>(player.Inventory.GetBackPackItems()); foreach (var item in bpItems) { var msg = new InventoryDropItemMessage { ItemID = item.DynamicID }; player.Inventory.Consume(invokerClient.InGameClient, msg); } return(string.Format("Dropped {0} Items for you", bpItems.Count)); }
public string Conversation(string[] @params, LogNetClient invokerClient) { if (invokerClient == null) { return("You can not invoke this command from console."); } if (invokerClient.InGameClient == null) { return("You can only invoke this command while ingame."); } if (@params.Count() != 1) { return("Invalid arguments. Type 'help conversation' to get help."); } try { var conversation = MPQStorage.Data.Assets[SNOGroup.Conversation][Int32.Parse(@params[0])]; invokerClient.InGameClient.Player.Conversations.StartConversation(Int32.Parse(@params[0])); return(String.Format("Started conversation {0}", conversation.FileName)); } catch (Exception e) { return(e.Message); } }
public string LevelUp(string[] @params, LogNetClient invokerClient) { if (invokerClient == null) { return("You can not invoke this command from console."); } if (invokerClient.InGameClient == null) { return("You can only invoke this command while ingame."); } var player = invokerClient.InGameClient.Player; var amount = 1; if (@params != null) { if (!Int32.TryParse(@params[0], out amount)) { amount = 1; } } for (int i = 0; i < amount; i++) { player.UpdateExp(player.Attributes[Net.GS.Message.GameAttribute.Experience_Next]); } player.Toon.GameAccount.NotifyUpdate(); return(string.Format("New level: {0}", player.Toon.Level)); }
public string Portal(string[] @params, LogNetClient invokerClient) { if (invokerClient == null) { return("You can not invoke this command from console."); } if (invokerClient.InGameClient == null) { return("You can only invoke this command while ingame."); } var world = invokerClient.InGameClient.Game.GetWorld(71150); if (world != invokerClient.InGameClient.Player.World) { invokerClient.InGameClient.Player.ChangeWorld(world, world.StartingPoints.First().Position); } else { invokerClient.InGameClient.Player.Teleport(world.StartingPoints.First().Position); } return(string.Format("Teleported back to town.")); }
public GameFactory(LogNetClient owner, bnet.protocol.game_master.FindGameRequest request, ulong requestId) : base(owner, true) { this.Started = false; this.Owner = owner; //Game is really the owner Channel.Owner should maybe be EntityId instead of LogNetClient -Egris this.RequestId = requestId; this.FactoryID = request.FactoryId; this.BnetEntityId = bnet.protocol.EntityId.CreateBuilder().SetHigh((ulong)EntityIdHelper.HighIdType.GameId).SetLow(this.DynamicId).Build(); this.GameHandle = bnet.protocol.game_master.GameHandle.CreateBuilder().SetFactoryId(this.FactoryID).SetGameId(this.BnetEntityId).Build(); foreach (bnet.protocol.attribute.Attribute attribute in request.Properties.CreationAttributesList) { if (attribute.Name != "GameCreateParams") { Logger.Warn("FindGame(): Unknown CreationAttribute: {0}", attribute.Name); } else { this.GameCreateParams = D3.OnlineService.GameCreateParams.ParseFrom(attribute.Value.MessageValue); } } foreach (bnet.protocol.attribute.Attribute attribute in request.Properties.Filter.AttributeList) { if (attribute.Name != "version") { Logger.Warn("FindGame(): Unknown Attribute: {0}", attribute.Name); } else { this.Version = attribute.Value.StringValue; } } }
public string Show(string[] @params, LogNetClient invokerClient) { if (@params.Count() < 1) { return("Invalid arguments. Type 'help rpcobject show' to get help."); } ulong localId; var id = @params[0]; if (!ulong.TryParse(id, out localId)) { return(string.Format("Can not parse '{0}' as valid id.", id)); } if (!RPCObjectManager.Objects.ContainsKey(localId)) { return(string.Format("There exists no RPCObject with dynamidId: {0}", localId)); } var rpcObject = RPCObjectManager.Objects[localId]; var output = string.Format("[RPCObject]\nDynamicId: 0x{0}\nType: {1}\nObject: {2}\n", rpcObject.DynamicId, rpcObject.GetType().Name, rpcObject); output += "[Subscribers]\n"; foreach (var client in rpcObject.Subscribers) { var remoteId = client.GetRemoteObjectId(rpcObject.DynamicId); output += string.Format("RemoteId: 0x{0} - {1}\n", remoteId.ToString("X8"), client.Account.Email); } return(output); }
public string AddGold(string[] @params, LogNetClient invokerClient) { if (invokerClient == null) { return("You can not invoke this command from console."); } if (invokerClient.InGameClient == null) { return("You can only invoke this command while ingame."); } if (@params == null) { return("Enter a amount to get gold."); } foreach (char ch in @params[0]) { if (!Char.IsNumber(ch) && ch != 32) { return("Only integer values"); } } Player player = invokerClient.InGameClient.Player; Int32 goldAdded = Int32.Parse(@params[0]); player.Inventory.AddGoldAmount(goldAdded); return(string.Format("Added {0} gold.", goldAdded)); }
public void RemoveMember(LogNetClient client, RemoveReason reason, bool dissolving) { if (client.Account.CurrentGameAccount == null) { Logger.Warn("Could not remove client {0} from channel {1}.", client.Connection.RemoteEndPoint.ToString(), this.ToString()); return; } else if (!HasUser(client)) { Logger.Warn("Attempted to remove non-member client {0} from channel {1}.", client.Connection.RemoteEndPoint.ToString(), this.ToString()); return; } else if (!client.Channels.ContainsValue(this)) { Logger.Warn("Client {0} being removed from a channel ({1}) he's not associated with.", client.Connection.RemoteEndPoint.ToString(), this.ToString()); } //else if (client.CurrentChannel != this) //{ // Logger.Warn("Client {0} is being removed from a channel ({1}) that is not its current one.", client.Connection.RemoteEndPoint.ToString(), this.ToString()); //} var memberId = this.Members[client].Identity.GameAccountId; var message = bnet.protocol.channel.RemoveNotification.CreateBuilder() .SetAgentId(memberId) //is this channel owner, member being removed or the one requesting removal of member? -Egris .SetMemberId(memberId) .SetReason((uint)reason) .Build(); //Logger.Debug("NotifyRemove message:\n{0}", message.ToString()); foreach (var pair in this.Members) { pair.Key.MakeTargetedRPC(this, () => bnet.protocol.channel.ChannelSubscriber.CreateStub(pair.Key).NotifyRemove(null, message, callback => { })); } this.Members.Remove(client); client.CurrentChannel = null; //client.Channels.Remove(this.DynamicId); //Add this when CurrentChannel is fully removed from code -Egris if (this.IsGameChannel) { client.GameChannel = null; Logger.Warn("Client {0} left game channel {1}.", client, this); } else { client.PartyChannel = null; Logger.Warn("Client {0} left party channel {1}.", client, this); } if (client == this.Owner) { this.Owner = null; } if (this.Members.Count == 0 && !dissolving) { Dissolve(); } }
public static GameFactory CreateGame(LogNetClient owner, bnet.protocol.game_master.FindGameRequest request, ulong requestId) { var gameFactory = new GameFactory(owner, request, requestId); GameCreators.Add(gameFactory.DynamicId, gameFactory); ChannelManager.AddGameChannel(gameFactory); return(gameFactory); }
public static void HandleAccept(LogNetClient client, bnet.protocol.invitation.GenericRequest request) { if (!OnGoingInvitations.ContainsKey(request.InvitationId)) { return; } var invitation = OnGoingInvitations[request.InvitationId]; var inviter = AccountManager.GetAccountByPersistentID(invitation.InviterIdentity.AccountId.Low); var invitee = AccountManager.GetAccountByPersistentID(invitation.InviteeIdentity.AccountId.Low); var inviteeAsFriend = bnet.protocol.friends.Friend.CreateBuilder().SetId(invitation.InviteeIdentity.AccountId).Build(); var inviterAsFriend = bnet.protocol.friends.Friend.CreateBuilder().SetId(invitation.InviterIdentity.AccountId).Build(); var notificationToInviter = bnet.protocol.friends.InvitationNotification.CreateBuilder() .SetGameAccountId(invitee.BnetEntityId) .SetInvitation(invitation) .SetReason((uint)InvitationRemoveReason.Accepted) // success? .Build(); var notificationToInvitee = bnet.protocol.friends.InvitationNotification.CreateBuilder() .SetGameAccountId(inviter.BnetEntityId) .SetInvitation(invitation) .SetReason((uint)InvitationRemoveReason.Accepted) // success? .Build(); AddFriendshipToDB(inviter, invitee); // send friend added notifications var friendAddedNotificationToInviter = bnet.protocol.friends.FriendNotification.CreateBuilder().SetTarget(inviteeAsFriend).SetGameAccountId(invitee.BnetEntityId).Build(); var friendAddedNotificationToInvitee = bnet.protocol.friends.FriendNotification.CreateBuilder().SetTarget(inviterAsFriend).SetGameAccountId(inviter.BnetEntityId).Build(); var inviterGameAccounts = GameAccountManager.GetGameAccountsForAccount(inviter); var inviteeGameAccounts = GameAccountManager.GetGameAccountsForAccount(invitee); foreach (var inviterGameAccount in inviterGameAccounts) { if (inviterGameAccount.IsOnline) { inviterGameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, () => bnet.protocol.friends.FriendsNotify.CreateStub(inviterGameAccount.LoggedInClient).NotifyReceivedInvitationRemoved(null, notificationToInviter, callback => { })); inviterGameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, () => bnet.protocol.friends.FriendsNotify.CreateStub(inviterGameAccount.LoggedInClient).NotifyFriendAdded(null, friendAddedNotificationToInviter, callback => { })); } } foreach (var inviteeGameAccount in inviteeGameAccounts) { if (inviteeGameAccount.IsOnline) { inviteeGameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, () => bnet.protocol.friends.FriendsNotify.CreateStub(inviteeGameAccount.LoggedInClient).NotifyFriendAdded(null, friendAddedNotificationToInvitee, callback => { })); inviteeGameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, () => bnet.protocol.friends.FriendsNotify.CreateStub(inviteeGameAccount.LoggedInClient).NotifyReceivedInvitationRemoved(null, notificationToInvitee, callback => { })); } } }
private void SendConnectionInfo(LogNetClient client) { // Lock party and close privacy level while entering game if (client.CurrentChannel != null) { var channelStatePrivacyLevel = bnet.protocol.channel.ChannelState.CreateBuilder() .SetPrivacyLevel(bnet.protocol.channel.ChannelState.Types.PrivacyLevel.PRIVACY_LEVEL_CLOSED).Build(); var notificationPrivacyLevel = bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder() .SetAgentId(client.Account.CurrentGameAccount.BnetEntityId) .SetStateChange(channelStatePrivacyLevel) .Build(); client.MakeTargetedRPC(client.CurrentChannel, () => bnet.protocol.channel.ChannelSubscriber.CreateStub(client).NotifyUpdateChannelState(null, notificationPrivacyLevel, callback => { })); var channelStatePartyLock = bnet.protocol.channel.ChannelState.CreateBuilder() .AddAttribute(bnet.protocol.attribute.Attribute.CreateBuilder() .SetName("D3.Party.LockReasons") .SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetIntValue(1).Build()) .Build()).Build(); var notificationPartyLock = bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder() .SetAgentId(client.Account.CurrentGameAccount.BnetEntityId) .SetStateChange(channelStatePartyLock) .Build(); client.MakeTargetedRPC(client.CurrentChannel, () => bnet.protocol.channel.ChannelSubscriber.CreateStub(client).NotifyUpdateChannelState(null, notificationPartyLock, callback => { })); } // send the notification. var connectionInfo = GetConnectionInfoForClient(client); var connectionInfoAttribute = bnet.protocol.attribute.Attribute.CreateBuilder().SetName("connection_info") .SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(connectionInfo.ToByteString()).Build()) .Build(); var gameHandleAttribute = bnet.protocol.attribute.Attribute.CreateBuilder().SetName("game_handle") .SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(this.GameHandle.ToByteString()).Build()) .Build(); var requestIdAttribute = bnet.protocol.attribute.Attribute.CreateBuilder().SetName("game_request_id") .SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetUintValue(this.RequestId).Build()) .Build(); var notificationBuilder = bnet.protocol.notification.Notification.CreateBuilder() .SetSenderId(bnet.protocol.EntityId.CreateBuilder().SetHigh((ulong)EntityIdHelper.HighIdType.GameAccountId).SetLow(0).Build()) .SetTargetId(client.Account.CurrentGameAccount.BnetEntityId) .SetType("GAME_ENTRY") .AddAttribute(connectionInfoAttribute) .AddAttribute(gameHandleAttribute) .AddAttribute(requestIdAttribute) .Build(); client.MakeRPC(() => bnet.protocol.notification.NotificationListener.CreateStub(client).OnNotificationReceived(null, notificationBuilder, callback => { })); }
public string WhoAmI(string[] @params, LogNetClient invokerClient) { if (invokerClient == null) { return("You can not invoke this command from console."); } return(string.Format("Email: {0} User Level: {1}", invokerClient.Account.Email, invokerClient.Account.UserLevel)); }
public string HashNormal(string[] @params, LogNetClient invokerClient) { if (@params.Count() < 1) { return("Invalid arguments. Type 'help hash show' to get help."); } return(StringHashHelper.HashNormal(@params[0]).ToString()); }
public static void SendAccountSettings(LogNetClient client) { var accset = new bnet.protocol.authentication.AccountSettingsNotification.Builder(); accset.AddLicenses(new bnet.protocol.account.AccountLicense.Builder().SetId(111)); accset.AddLicenses(new bnet.protocol.account.AccountLicense.Builder().SetId(227)); accset.AddLicenses(new bnet.protocol.account.AccountLicense.Builder().SetId(168)); //Full Game - Removes upgrade banner client.MakeRPC(() => bnet.protocol.authentication.AuthenticationClient.CreateStub(client).AccountSettings(null, accset.Build(), delegate(bnet.protocol.NO_RESPONSE a) { })); }
/// <summary> /// Notifies a specific subscriber about the object's present state. /// This methods should be actually implemented by deriving object classes. /// </summary> /// <param name="client">The subscriber.</param> protected void NotifySubscriptionAdded(LogNetClient client) { var operations = GetSubscriptionNotifications(); if (operations.Count > 0) { MakeRPC(client, operations); } }