예제 #1
0
        public void Handle(Message message)
        {
            // Find out the thing we need to echo back.
            var value = (message.Content as UnknownContent).Data["value"] as string;

            // Send the echo both as an output and as a reply so that clients
            // can test both kinds of callbacks.
            shellServer.SendIoPubMessage(
                new Message
            {
                Header = new MessageHeader
                {
                    MessageType = "iqsharp_echo_output"
                },
                Content = new EchoReplyContent
                {
                    Value = value
                }
            }.AsReplyTo(message)
                );
            shellServer.SendShellMessage(
                new Message
            {
                Header = new MessageHeader
                {
                    MessageType = "iqsharp_echo_reply"
                },
                Content = new EchoReplyContent
                {
                    Value = value
                }
            }.AsReplyTo(message)
                );
        }
예제 #2
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)
         );
 }
예제 #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)
                               ));
        }