Exemple #1
0
 public void Handle(Message message)
 {
     metadata.UserAgent = (message.Content as UnknownContent).Data["user_agent"] as string;
     shellServer.SendShellMessage(
         new Message
     {
         Header = new MessageHeader
         {
             MessageType = "iqsharp_clientinfo_reply"
         },
         Content = metadata.AsClientInfoContent()
     }
         .AsReplyTo(message)
         );
 }
Exemple #2
0
        public ClientInfoListener(
            ILogger <ClientInfoListener> logger,
            IMetadataController metadata,
            ICommsRouter commsRouter
            )
        {
            this.logger      = logger;
            this.metadata    = metadata;
            this.commsRouter = commsRouter;

            logger.LogDebug("Started client info listener.");
            commsRouter.SessionOpenEvent("iqsharp_clientinfo").On += async(session, data) =>
            {
                logger.LogDebug("Got iqsharp_clientinfo message: {Data}", data.ToString());
                if (!data.TryAs <ClientInfoContent>(out var content))
                {
                    logger.LogError(
                        "Got client info via comms, but failed to deserialize:\n{RawData}",
                        data.ToString()
                        );
                    return;
                }
                metadata.UserAgent         = content.UserAgent ?? metadata.UserAgent;
                metadata.ClientId          = content.ClientId ?? metadata.ClientId;
                metadata.ClientIsNew       = content.ClientIsNew ?? metadata.ClientIsNew;
                metadata.ClientCountry     = content.ClientCountry ?? metadata.ClientCountry;
                metadata.ClientLanguage    = content.ClientLanguage ?? metadata.ClientLanguage;
                metadata.ClientHost        = content.ClientHost ?? metadata.ClientHost;
                metadata.ClientOrigin      = content.ClientOrigin ?? metadata.ClientOrigin;
                metadata.ClientFirstOrigin = content.ClientFirstOrigin ?? metadata.ClientFirstOrigin;
                await Task.Run(() =>
                {
                    session.SendMessage(
                        metadata.AsClientInfoContent()
                        );
                    session.Close();
                });
            };
        }
Exemple #3
0
        /// <inheritdoc />
        public async Task HandleAsync(Message message)
        {
            var content = message.To <ClientInfoContent>();

            metadata.UserAgent         = content.UserAgent ?? metadata.UserAgent;
            metadata.ClientId          = content.ClientId ?? metadata.ClientId;
            metadata.ClientIsNew       = content.ClientIsNew ?? metadata.ClientIsNew;
            metadata.ClientCountry     = content.ClientCountry ?? metadata.ClientCountry;
            metadata.ClientLanguage    = content.ClientLanguage ?? metadata.ClientLanguage;
            metadata.ClientHost        = content.ClientHost ?? metadata.ClientHost;
            metadata.ClientOrigin      = content.ClientOrigin ?? metadata.ClientOrigin;
            metadata.ClientFirstOrigin = content.ClientFirstOrigin ?? metadata.ClientFirstOrigin;
            await Task.Run(() => shellServer.SendShellMessage(
                               new Message
            {
                Header = new MessageHeader
                {
                    MessageType = "iqsharp_clientinfo_reply"
                },
                Content = metadata.AsClientInfoContent()
            }
                               .AsReplyTo(message)
                               ));
        }