public void HandleMessage(Message message, RouterSocket serverSocket, PublisherSocket ioPub)
        {
            Message replyMessage = new Message(MessageType.KernelInfoReply, CreateKernelInfoReply(), message.Header);

            _logger.LogInformation("Sending kernel_info_reply");
            serverSocket.SendMessage(replyMessage);
        }
        public void HandleMessage(Message message, RouterSocket serverSocket, PublisherSocket ioPub)
        {
            TargetName targetName   = message.Content as TargetName;
            Message    replyMessage = new Message(MessageType.CommInfoReply, CreateCommInfoReply(targetName), message.Header);

            _logger.LogInformation("Sending comm_info_reply");
            serverSocket.SendMessage(replyMessage);
        }
        public void HandleMessage(Message message, RouterSocket serverSocket, PublisherSocket ioPub)
        {
            var shutdownRequest = message.Content as ShutdownContent;

            _logger.LogInformation("Stopping heartbeat");
            _heartbeat.Stop();

            Message replyMessage = new Message(MessageType.ShutDownReply, shutdownRequest, message.Header);

            _logger.LogInformation("Sending shutdown_response");
            serverSocket.SendMessage(replyMessage);

            _logger.LogInformation("Stopping shell");
            _shell.Stop();
        }
        public void SendExecuteReplyMessage(Message request, RouterSocket shellSocket)
        {
            var content = new ExecuteResultReplyContent()
            {
                ExecutionCount  = this._executionCount,
                Payload         = new List <Dictionary <string, string> >(),
                UserExpressions = new Dictionary <string, string>()
            };

            Message message = new Message(MessageType.ExecuteReply, content, request.Header)
            {
                // Stick the original identifiers on the message so they'll be sent first
                // Necessary since the shell socket is a ROUTER socket
                Identifiers = request.Identifiers
            };

            this._logger.LogInformation(string.Format("Sending message to Shell {0}", JsonConvert.SerializeObject(message)));
            shellSocket.SendMessage(message);
        }
        public void SendExecuteErrorMessage(Message request, RouterSocket shellSocket, IErrorResult error)
        {
            var content = new ExecuteErrorReplyContent()
            {
                ExecutionCount = _executionCount,
                //EName = error.Name,
                //EValue = error.Message,
                //Traceback = error.StackTrace
            };

            Message message = new Message(MessageType.ExecuteReply, content, request.Header)
            {
                // Stick the original identifiers on the message so they'll be sent first
                // Necessary since the shell socket is a ROUTER socket
                Identifiers = request.Identifiers
            };

            this._logger.LogInformation(string.Format("Sending message to Shell {0}", JsonConvert.SerializeObject(message)));
            shellSocket.SendMessage(message);
        }
        private void RouterAction()
        {
            using (NetMQContext ctx = NetMQContext.Create())
            {
                using (RouterSocket socket = ctx.CreateRouterSocket())
                {
                    socket.Bind(Address);

                    while (true)
                    {
                        NetMQMessage message  = socket.ReceiveMessage();
                        string       topic    = message.Last.ConvertToString();
                        byte[]       snapshot = _snapshotFactory(topic);

                        var response = new NetMQMessage();
                        response.Append(message.First);
                        response.AppendEmptyFrame();
                        response.Append(snapshot);

                        socket.SendMessage(response);
                    }
                }
            }
        }