Пример #1
0
        private void HandleKernelInfoRequest(Envelope request)
        {
            var languageInfo    = GetLanguageInfo();
            var kernelInfoReply = new KernelInfoReply(Constants.MESSAGE_PROTOCOL_VERSION, ".NET", "5.1.0", languageInfo);

            _shellSender.Reply(kernelInfoReply, request);
        }
Пример #2
0
        private void HandleKernelInfoRequest(ZeroMQMessage request)
        {
            var languageInfo    = GetLanguageInfo();
            var kernelInfoReply = new KernelInfoReply(Constants.MESSAGE_PROTOCOL_VERSION, ".NET", "5.1.0", languageInfo);

            _shellChannel.Reply(kernelInfoReply, request);
        }
Пример #3
0
        public void KernelInfoReply_contract_has_not_been_broken()
        {
            var socket          = new TextSocket();
            var sender          = new MessageSender(socket, new SignatureValidator("key", "HMACSHA256"));
            var kernelInfoReply = new KernelInfoReply(
                Constants.MESSAGE_PROTOCOL_VERSION,
                ".NET",
                "0.0.3",
                new LanguageInfo(
                    name: "C#",
                    version: typeof(string).Assembly.ImageRuntimeVersion.Substring(1),
                    mimeType: "text/x-csharp",
                    fileExtension: ".cs",
                    pygmentsLexer: "c#"
                    ));
            var header = new Header(messageType: JupyterMessageContentTypes.KernelInfoReply, messageId: Guid.Empty.ToString(),
                                    version: Constants.MESSAGE_PROTOCOL_VERSION, username: Constants.USERNAME, session: "test session",
                                    date: DateTime.MinValue.ToString("yyyy-MM-ddTHH:mm:ssZ"));
            var replyMessage = new Message(header, content: kernelInfoReply);

            sender.Send(replyMessage);

            var encoded = socket.GetEncodedMessage();

            this.Assent(encoded, _configuration);
        }
Пример #4
0
 public JupyterRequestContext(IJupyterMessageSender jupyterMessageSender, Envelope
                              request, string kernelIdentity)
 {
     JupyterMessageSender = jupyterMessageSender ?? throw new ArgumentNullException(nameof(jupyterMessageSender));
     Request        = request ?? throw new ArgumentNullException(nameof(request));
     KernelIdentity = kernelIdentity;
 }
Пример #5
0
        public void Display_data_contract_has_not_been_broken()
        {
            var socket    = new TextSocket();
            var sender    = new MessageSender(socket, new SignatureValidator("key", "HMACSHA256"));
            var transient = new Dictionary <string, object> {
                { "display_id", "none" }
            };
            var output      = "some result";
            var displayData = new DisplayData(
                data: new Dictionary <string, object>
            {
                { "text/html", output },
                { "text/plain", output }
            },
                transient: transient);


            var header = new Header(messageType: JupyterMessageContentTypes.DisplayData, messageId: Guid.Empty.ToString(),
                                    version: "5.3", username: Constants.USERNAME, session: "test session",
                                    date: DateTime.MinValue.ToString("yyyy-MM-ddTHH:mm:ssZ"));
            var replyMessage = new Message(header, content: displayData);

            sender.Send(replyMessage);

            var encoded = socket.GetEncodedMessage();

            this.Assent(encoded, _configuration);
        }
Пример #6
0
        public void Input_cell_honors_custom_metadata()
        {
            var socket    = new TextSocket();
            var sender    = new MessageSender(socket, new SignatureValidator("key", "HMACSHA256"));
            var transient = new Dictionary <string, object> {
                { "display_id", "none" }
            };
            var output        = "some result";
            var executeResult = new ExecuteResult(
                12,
                transient: transient,
                data: new Dictionary <string, object> {
                { "text/html", output },
                { "text/plain", output }
            });

            var header = new Header(messageType: JupyterMessageContentTypes.ExecuteResult, messageId: Guid.Empty.ToString(),
                                    version: "5.3", username: Constants.USERNAME, session: "test session",
                                    date: DateTime.MinValue.ToString("yyyy-MM-ddTHH:mm:ssZ"));

            var metaData = new Dictionary <string, object>
            {
                { "dotnet_interactive", new InputCellMetadata("fsharp") }
            };

            var replyMessage = new Message(header, content: executeResult, metaData: metaData);

            sender.Send(replyMessage);

            var encoded = socket.GetEncodedMessage();

            this.Assent(encoded, _configuration);
        }
Пример #7
0
 public JupyterRequestContext(IJupyterMessageSender jupyterMessageSender, ZeroMQMessage
                              request)
 {
     Token = Guid.NewGuid().ToString("N");
     JupyterMessageSender          = jupyterMessageSender ?? throw new ArgumentNullException(nameof(jupyterMessageSender));
     JupyterRequestMessageEnvelope = request ?? throw new ArgumentNullException(nameof(request));
 }
Пример #8
0
        public void Complete_reply_contract_has_not_been_broken()
        {
            var socket = new TextSocket();
            var sender = new MessageSender(socket, new SignatureValidator("key", "HMACSHA256"));

            var completeReply = new CompleteReply(0, 0, matches: new List <string> {
                "Write", "WriteLine"
            });

            var header = new Header(messageType: JupyterMessageContentTypes.CompleteReply, messageId: Guid.Empty.ToString(),
                                    version: "5.3", username: Constants.USERNAME, session: "test session",
                                    date: DateTime.MinValue.ToString("yyyy-MM-ddTHH:mm:ssZ"));

            var replyMessage = new Message(header, content: completeReply);

            sender.Send(replyMessage);

            var encoded = socket.GetEncodedMessage();

            this.Assent(encoded, _configuration);
        }
Пример #9
0
 internal JupyterRequestContext(ReplyChannel serverChannel, PubSubChannel ioPubChannel, Envelope
                                request, string kernelIdentity) :
     this(new JupyterMessageSender(ioPubChannel, serverChannel, kernelIdentity, request), request, kernelIdentity)
 {
 }
Пример #10
0
 public JupyterRequestContext(IJupyterMessageSender jupyterMessageSender, Envelope
                              request)
 {
     JupyterMessageSender = jupyterMessageSender ?? throw new ArgumentNullException(nameof(jupyterMessageSender));
     Request = request ?? throw new ArgumentNullException(nameof(request));
 }
Пример #11
0
 internal JupyterRequestContext(ReplyChannel serverChannel, PubSubChannel ioPubChannel, StdInChannel stdInChannel, ZeroMQMessage request, string kernelIdentity)
     : this(new JupyterMessageSender(ioPubChannel, serverChannel, stdInChannel, kernelIdentity, request), request)
 {
 }