コード例 #1
0
        private void PublishError(Message request, PublisherSocket ioPub, IErrorResult error)
        {
            // Write to Stderr first -- then write the ExecuteError
            var     errorMessage = new StderrContent(error.Message);
            Message message      = new Message(MessageType.Stream, errorMessage, request.Header)
            {
                Identifiers = request.Identifiers
            };

            this._logger.LogInformation(string.Format("Sending message to IOPub {0}", JsonConvert.SerializeObject(message)));
            ioPub.SendMessage(message);


            var executeReply = new ExecuteErrorPublishContent()
            {
                ExecutionCount = _executionCount,
                EName          = error.Name,
                EValue         = error.Message,
                Traceback      = error.StackTrace
            };

            message = new Message(MessageType.Error, executeReply, request.Header)
            {
                Identifiers = request.Identifiers
            };
            this._logger.LogInformation(string.Format("Sending message to IOPub {0}", JsonConvert.SerializeObject(message)));
            ioPub.SendMessage(message);
        }
コード例 #2
0
        public void PublishInput(Message request, PublisherSocket ioPub, string code)
        {
            var     content = new ExecuteRequestPublishContent(code, _executionCount);
            Message message = new Message(MessageType.Input, content, request.Header);

            this._logger.LogInformation(string.Format("Sending message to IOPub {0}", JsonConvert.SerializeObject(message)));
            ioPub.SendMessage(message);
        }
コード例 #3
0
        public void PublishOutput(Message request, PublisherSocket ioPub, DisplayDataContent data)
        {
            var     content = new ExecuteResultPublishContent(data, _executionCount);
            Message message = new Message(MessageType.ExecuteResult, content, request.Header);

            this._logger.LogInformation(string.Format("Sending message to IOPub {0}", JsonConvert.SerializeObject(message)));
            ioPub.SendMessage(message);
        }
コード例 #4
0
        public void PublishStatus(Message request, PublisherSocket ioPub, KernelState statusValue)
        {
            Message message = new Message(MessageType.Status, new StatusContent(statusValue), request.Header);

            this._logger.LogInformation(string.Format("Sending message to IOPub {0}", JsonConvert.SerializeObject(message)));
            ioPub.SendMessage(message);
            this._logger.LogInformation("Message Sent");
        }
コード例 #5
0
        protected override void ConsumerAction()
        {
            using (NetMQContext ctx = NetMQContext.Create())
            {
                using (PublisherSocket socket = ctx.CreatePublisherSocket())
                {
                    socket.Bind(Address);

                    foreach (NetMQMessage message in Queue.GetConsumingEnumerable())
                    {
                        socket.SendMessage(message);
                    }
                }
            }
        }
コード例 #6
0
 public void SendMessage(SerializedMessage message) => PublisherSocket.SendMessage(message);