Example #1
0
        public int?SendMessageToCharacter(ScsCharacterMessage message)
        {
            if (!MsManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return(null);
            }

            WorldServer sourceWorld = MsManager.Instance.WorldServers.Find(s => s.Id.Equals(message.SourceWorldId));

            if (message?.Message == null || sourceWorld == null)
            {
                return(null);
            }
            switch (message.Type)
            {
            case MessageType.Family:
            case MessageType.FamilyChat:
                foreach (WorldServer world in MsManager.Instance.WorldServers.Where(w => w.WorldGroup.Equals(sourceWorld.WorldGroup)))
                {
                    world.CommunicationServiceClient.GetClientProxy <ICommunicationClient>().SendMessageToCharacter(message);
                }
                return(-1);

            case MessageType.PrivateChat:
            case MessageType.Whisper:
            case MessageType.WhisperSupport:
            case MessageType.WhisperGm:
                if (message.DestinationCharacterId.HasValue)
                {
                    AccountConnection account = MsManager.Instance.ConnectedAccounts.Find(a => a.CharacterId.Equals(message.DestinationCharacterId.Value));
                    if (account?.ConnectedWorld != null)
                    {
                        account.ConnectedWorld.CommunicationServiceClient.GetClientProxy <ICommunicationClient>().SendMessageToCharacter(message);
                        return(account.ConnectedWorld.ChannelId);
                    }
                }
                break;

            case MessageType.Shout:
                foreach (WorldServer world in MsManager.Instance.WorldServers)
                {
                    world.CommunicationServiceClient.GetClientProxy <ICommunicationClient>().SendMessageToCharacter(message);
                }
                return(-1);
            }
            return(null);
        }
Example #2
0
 public int?SendMessageToCharacter(ScsCharacterMessage message) => _client.ServiceProxy.SendMessageToCharacter(message);
Example #3
0
 internal void OnSendMessageToCharacter(ScsCharacterMessage message) => MessageSentToCharacter?.Invoke(message, null);
 public void SendMessageToCharacter(ScsCharacterMessage message) => Task.Run(() => CommunicationServiceClient.Instance.OnSendMessageToCharacter(message));