예제 #1
0
        private void SendChatMessageToGroup(ChatMessage message)
        {
            log.InfoFormat("SendChatMessageToGroup() called yellow");

            SelectCharacterClientPeer peer = null;

            if (!mApplication.Clients.TryGetPeerForCharacterId(message.sourceCharacterID, out peer))
            {
                log.InfoFormat("Source message peer not founded yellow");
                return;
            }
            string groupID = peer.groupID;

            if (string.IsNullOrEmpty(groupID))
            {
                log.InfoFormat("Send message to group = {0}. Group not founded.", groupID);
                return;
            }

            mApplication.Clients.SendChatMessageToGroup(groupID, message);

            mCache.AddMessage(message);

            log.InfoFormat("chat message sended to group = {0} yellow", groupID);
        }
예제 #2
0
        /// <summary>
        /// Set guild for player character
        /// </summary>
        public void SetGuild(string gameRefID, string characterID, string guildID)
        {
            DbObjectWrapper <DbPlayerCharactersObject> player = GetExistingPlayer(gameRefID);

            if (player == null)
            {
                log.InfoFormat("plaer = {0} not exists", gameRefID);
                return;
            }

            player.Data.SetGuild(characterID, guildID);
            player.Changed = true;

            SelectCharacterClientPeer peer = null;

            if (mApplication.Clients.TryGetPeerForGameRefId(player.Data.GameRefId, out peer))
            {
                if (peer != null)
                {
                    CharacterUpdateEvent evt = new CharacterUpdateEvent {
                        Characters = player.Data.GetInfo()
                    };
                    EventData eventData = new EventData((byte)SelectCharacterEventCode.CharactersUpdate, evt);
                    peer.SendEvent(eventData, new SendParameters());
                }
            }
        }
예제 #3
0
        private void SendChatMessageToCharacterName(ChatMessage message)
        {
            SelectCharacterClientPeer sourcePeer = null;

            if (!mApplication.Clients.TryGetPeerForCharacterId(message.sourceCharacterID, out sourcePeer))
            {
                log.Info("source peer not founded");
                return;
            }

            var sourcePlayer = mApplication.Players.GetExistingPlayerByLogin(message.sourceLogin);

            if (sourcePlayer == null)
            {
                log.Info("source player not founded");
                return;
            }

            var sourceCharacter = sourcePlayer.Data.GetCharacter(sourcePlayer.Data.SelectedCharacterId);

            if (sourceCharacter == null)
            {
                log.Info("source character not founded");
                return;
            }

            if (string.IsNullOrEmpty(message.targetCharacterName))
            {
                log.InfoFormat("target character name not setted");
                return;
            }

            var targetPlayer = mApplication.Players.GetCachePlayerByCharacterName(message.targetCharacterName);

            if (targetPlayer == null)
            {
                log.InfoFormat("player with such character name not cached");
                return;
            }

            SelectCharacterClientPeer targetPeer;

            if (false == mApplication.Clients.TryGetPeerForCharacterId(targetPlayer.Data.SelectedCharacterId, out targetPeer))
            {
                log.InfoFormat("target peer not found");
                return;
            }

            message.targetCharacterID = targetPlayer.Data.SelectedCharacterId;
            message.targetLogin       = targetPlayer.Data.Login;

            sourcePeer.SendChatMessage(message);
            targetPeer.SendChatMessage(message);
            mCache.AddMessage(message);
        }
예제 #4
0
        private void SendChatMessageToGuild(ChatMessage message)
        {
            SelectCharacterClientPeer sourcePeer = null;

            if (!mApplication.Clients.TryGetPeerForCharacterId(message.sourceCharacterID, out sourcePeer))
            {
                log.Info("source peer not founded");
                return;
            }

            var sourcePlayer = mApplication.Players.GetExistingPlayerByLogin(message.sourceLogin);

            if (sourcePlayer == null)
            {
                log.Info("source player not founded");
                return;
            }

            var sourceCharacter = sourcePlayer.Data.GetCharacter(sourcePlayer.Data.SelectedCharacterId);

            if (sourceCharacter == null)
            {
                log.Info("source character not founded");
                return;
            }

            if (string.IsNullOrEmpty(sourceCharacter.guildID))
            {
                log.Info("source character don't have guild");
                return;
            }

            var guild = mApplication.Guilds.GetGuild(sourceCharacter.guildID);

            if (guild == null)
            {
                log.Info("guild not founded");
                return;
            }

            var characterIDs = guild.guildCharacters;

            foreach (var character in characterIDs)
            {
                SelectCharacterClientPeer peer = null;
                if (mApplication.Clients.TryGetPeerForCharacterId(character, out peer))
                {
                    peer.SendChatMessage(message);
                }
            }
            mCache.AddMessage(message);
        }
예제 #5
0
        private void SendGuildUpdateEvent(string characterID, Hashtable guildInfo)
        {
            SelectCharacterClientPeer peer = null;

            if (mApplication.Clients.TryGetPeerForCharacterId(characterID, out peer))
            {
                GuildUpdateEvent updateEvent = new GuildUpdateEvent {
                    Guild = guildInfo
                };
                EventData eventData = new EventData((byte)SelectCharacterEventCode.GuildUpdate, updateEvent);
                if (false == peer.Disposed)
                {
                    peer.SendEvent(eventData, new SendParameters());
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Set notification to character and send event to client if connected
        /// </summary>
        /// <param name="characterID">character id</param>
        /// <param name="notification">notification</param>
        public void SetNotificationToCharacter(string characterID, Notification notification)
        {
            log.Info("start setting notification to player");

            //get notification from cache or database
            var notifications = GetNotifications(characterID);

            log.InfoFormat("current notifications count = {0}", notifications.notifications.Count);

            //if not found exit
            if (notifications == null)
            {
                log.InfoFormat("not found notifications for character = {0}", characterID);
                return;
            }

            if (notifications.Contains(notification))
            {
                log.InfoFormat("SetNotificationToCharacter: notification with same unique ID already setted on character, duplicates not allowed [green]");
                return;
            }
            //add notfication to cached object
            notifications.Add(notification);
            //mark notfication for this character changed(for later savinf to database)
            mCache.SetChanged(characterID, true);

            log.InfoFormat("after setting notifications count = {0}", notifications.notifications.Count);

            //find peer for client (if such exists) or exit if peer with this character not founded
            SelectCharacterClientPeer peer = null;

            if (!mApplication.Clients.TryGetPeerForCharacterId(characterID, out peer))
            {
                log.InfoFormat("event to client about notification not sended, peer not found = {0}", characterID);
                return;
            }

            if (peer != null)
            {
                //send event to client about new notification
                EventData eventData = new EventData((byte)SelectCharacterEventCode.NotificationUpdate, new NotificationUpdateEvent {
                    Notifications = notifications.GetInfo()
                });
                peer.SendEvent(eventData, new SendParameters());
                log.InfoFormat("sended event to peer");
            }
        }
예제 #7
0
        private void SendChatMessageToRace(ChatMessage message)
        {
            SelectCharacterClientPeer sourcePeer = null;

            if (!mApplication.Clients.TryGetPeerForCharacterId(message.sourceCharacterID, out sourcePeer))
            {
                log.Info("[SendChatMessageToRace]: source peer not founded [purple]");
                return;
            }

            if (sourcePeer.selectedCharacter == null)
            {
                log.InfoFormat("[SendChatMessageToRace]: not found selected character at peer [purple]");
                return;
            }

            mApplication.Clients.SendChatMessageToRace((Race)(byte)sourcePeer.selectedCharacter.Race, message);
            mCache.AddMessage(message);
        }
예제 #8
0
        private void SendChatMessageToPlayer(ChatMessage message)
        {
            SelectCharacterClientPeer sourcePeer = null;

            if (!mApplication.Clients.TryGetPeerForCharacterId(message.sourceCharacterID, out sourcePeer))
            {
                log.Info("source peer not founded");
                return;
            }

            var sourcePlayer = mApplication.Players.GetExistingPlayerByLogin(message.sourceLogin);

            if (sourcePlayer == null)
            {
                log.Info("source player not founded");
                return;
            }

            var sourceCharacter = sourcePlayer.Data.GetCharacter(sourcePlayer.Data.SelectedCharacterId);

            if (sourceCharacter == null)
            {
                log.Info("source character not founded");
                return;
            }

            SelectCharacterClientPeer targetPeer;

            if (!mApplication.Clients.TryGetPeerForCharacterId(message.targetCharacterID, out targetPeer))
            {
                log.Info("target character not founded");
                return;
            }

            sourcePeer.SendChatMessage(message);
            targetPeer.SendChatMessage(message);
            mCache.AddMessage(message);
        }
예제 #9
0
        public void SetGuild(string characterId, string guildId)
        {
            DbObjectWrapper <DbPlayerCharactersObject> player = null;

            if (mCache.TryGetPlayerByCharacterId(characterId, out player))
            {
                player.Data.SetGuild(characterId, guildId);
                player.Changed = true;

                SelectCharacterClientPeer peer = null;
                if (mApplication.Clients.TryGetPeerForGameRefId(player.Data.GameRefId, out peer))
                {
                    if (peer != null)
                    {
                        CharacterUpdateEvent evt = new CharacterUpdateEvent {
                            Characters = player.Data.GetInfo()
                        };
                        EventData eventData = new EventData((byte)SelectCharacterEventCode.CharactersUpdate, evt);
                        peer.SendEvent(eventData, new SendParameters());
                    }
                }
            }
        }
예제 #10
0
        private void SendChatEventToZone(ChatMessage message)
        {
            SelectCharacterClientPeer sourcePeer = null;

            if (!mApplication.Clients.TryGetPeerForCharacterId(message.sourceCharacterID, out sourcePeer))
            {
                log.Info("source peer not founded");
                return;
            }

            var sourcePlayer = mApplication.Players.GetExistingPlayerByLogin(message.sourceLogin);

            if (sourcePlayer == null)
            {
                log.Info("source player not founded");
                return;
            }

            var sourceCharacter = sourcePlayer.Data.GetCharacter(sourcePlayer.Data.SelectedCharacterId);

            if (sourceCharacter == null)
            {
                log.Info("source character not founded");
                return;
            }

            if (string.IsNullOrEmpty(sourceCharacter.WorldId))
            {
                log.Info("source character world invalid");
                return;
            }

            log.InfoFormat("send message to world = {0}", sourceCharacter.WorldId);

            mApplication.Clients.SendChatMessageToWorld(sourceCharacter.WorldId, message);
            mCache.AddMessage(message);
        }
 public InviteToGuildOperationHandler(SelectCharacterApplication app, SelectCharacterClientPeer peer)
     : base(app, peer)
 {
 }
예제 #12
0
 public DeleteAuctionItemOperationHandler(SelectCharacterApplication app, SelectCharacterClientPeer peer)
     : base(app, peer)
 {
 }
예제 #13
0
 public SetNewPriceOperationHandler(SelectCharacterApplication app, SelectCharacterClientPeer peer)
     : base(app, peer)
 {
 }
 public SendPushToPlayersOperationHandler(SelectCharacterApplication app, SelectCharacterClientPeer peer)
     : base(app, peer)
 {
 }
 public SetGuildDescriptionOperationHandler(SelectCharacterApplication app, SelectCharacterClientPeer peer)
     : base(app, peer)
 {
 }
예제 #16
0
 public BuyPvpItemOperationHandler(SelectCharacterApplication app, SelectCharacterClientPeer peer)
     : base(app, peer)
 {
 }
 public MoveItemFromStationToBankOperationHandler(SelectCharacterApplication app, SelectCharacterClientPeer peer)
     : base(app, peer)
 {
 }
예제 #18
0
 public GetPlayerStoreOperationHandler(SelectCharacterApplication app, SelectCharacterClientPeer peer)
     : base(app, peer)
 {
 }
예제 #19
0
 public BaseOperationHandler(SelectCharacterApplication application, SelectCharacterClientPeer peer)
 {
     this.application = application;
     this.peer        = peer;
 }
예제 #20
0
 public RequestServerIDOperationHandler(SelectCharacterApplication context, SelectCharacterClientPeer peer)
     : base(context, peer)
 {
 }
 public HandleNotificationOperationHandler(SelectCharacterApplication app, SelectCharacterClientPeer peer)
     : base(app, peer)
 {
 }
 public RegisterClientOperationHandler(SelectCharacterApplication app, SelectCharacterClientPeer peer)
     : base(app, peer)
 {
 }
 public CreateCharacterOperationHandler(SelectCharacterApplication app, SelectCharacterClientPeer peer)
     : base(app, peer)
 {
 }
 public RPCInvokeMethodOperationHandler(SelectCharacterApplication app, SelectCharacterClientPeer peer)
     : base(app, peer)
 {
 }
예제 #25
0
 public MoveAttachmentToStationOperationHandler(SelectCharacterApplication app, SelectCharacterClientPeer peer)
     : base(app, peer)
 {
 }
예제 #26
0
 public ChangeGuildMemberStatusOperationHandler(SelectCharacterApplication app, SelectCharacterClientPeer peer)
     : base(app, peer)
 {
 }
 public WriteMessageOperationHandler(SelectCharacterApplication app, SelectCharacterClientPeer peer)
     : base(app, peer)
 {
 }
예제 #28
0
 public GetMailBoxOperationHandler(SelectCharacterApplication app, SelectCharacterClientPeer peer)
     : base(app, peer)
 {
 }