public static bool Send(Message message, NetMQSocket socket) { Send(message.UUID, socket); Send(Delimeter, socket); Send(string.Empty, socket); Send(JsonSerializer.Serialize(message.Header), socket); Send(JsonSerializer.Serialize(message.ParentHeader), socket); Send(JsonSerializer.Serialize(message.MetaData), socket); Send(message.Content, socket, false); return true; }
public static Message CreateMessage(string messageType, string content, Header parentHeader) { string session = parentHeader.Session; Message message = new Message() { UUID = session, ParentHeader = parentHeader, Header = MessageBuilder.CreateHeader(messageType, session), Content = content }; return message; }
public bool Send(Message message, NetMQSocket socket) { string hmac = this._signatureValidator.CreateSignature (message); Send(message.UUID, socket); Send(Delimeter, socket); Send(hmac, socket); Send(JsonSerializer.Serialize(message.Header), socket); Send(JsonSerializer.Serialize(message.ParentHeader), socket); Send(JsonSerializer.Serialize(message.MetaData), socket); Send(message.Content, socket, false); return true; }
public void SendExecuteReplyMessage(Message message, RouterSocket shellSocket) { ExecuteReplyOk executeReply = new ExecuteReplyOk() { ExecutionCount = this.executionCount, Payload = new List<Dictionary<string, string>>(), UserExpressions = new Dictionary<string, string>() }; Message executeReplyMessage = MessageBuilder.CreateMessage(MessageTypeValues.ExecuteReply, JsonSerializer.Serialize(executeReply), message.Header); this.logger.Info(string.Format("Sending message to Shell {0}", JsonSerializer.Serialize(executeReplyMessage))); MessageSender.Send(executeReplyMessage, shellSocket); }
public void HandleMessage(Message message, RouterSocket serverSocket, PublisherSocket ioPub) { KernelInfoRequest kernelInfoRequest = JsonSerializer.Deserialize<KernelInfoRequest>(message.Content); Message replyMessage = new Message() { UUID = message.Header.Session, ParentHeader = message.Header, Header = MessageBuilder.CreateHeader(MessageTypeValues.KernelInfoReply, message.Header.Session), Content = JsonSerializer.Serialize(this.CreateKernelInfoReply()) }; this.logger.Info("Sending kernel_info_reply"); MessageSender.Send(replyMessage, serverSocket); }
public void HandleMessage(Message message, RouterSocket serverSocket, PublisherSocket ioPub) { this.logger.Debug(string.Format("Message Content {0}", message.Content)); ExecuteRequest executeRequest = JsonSerializer.Deserialize<ExecuteRequest>(message.Content); this.logger.Info(string.Format("Execute Request received with code {0}", executeRequest.Code)); // 1: Send Busy status on IOPub this.SendMessageToIOPub(message, ioPub, StatusValues.Busy); // 2: Send execute input on IOPub this.SendInputMessageToIOPub(message, ioPub, executeRequest.Code); // 3: Evaluate the C# code string code = executeRequest.Code; ExecutionResult results = this.replEngine.Execute(code); string codeOutput = this.GetCodeOutput(results); string codeHtmlOutput = this.GetCodeHtmlOutput(results); Dictionary<string, object> data = new Dictionary<string, object>() { {"text/plain", codeOutput}, {"text/html", codeHtmlOutput} }; DisplayData displayData = new DisplayData() { Data = data, }; // 4: Send execute reply to shell socket this.SendExecuteReplyMessage(message, serverSocket); // 5: Send execute result message to IOPub this.SendOutputMessageToIOPub(message, ioPub, displayData); // 6: Send IDLE status message to IOPub this.SendMessageToIOPub(message, ioPub, StatusValues.Idle); this.executionCount += 1; }
public void SendInputMessageToIOPub(Message message, PublisherSocket ioPub, string code) { Dictionary<string, object> content = new Dictionary<string, object>(); content.Add("execution_count", 1); content.Add("code", code); Message executeInputMessage = MessageBuilder.CreateMessage(MessageTypeValues.Input, JsonSerializer.Serialize(content), message.Header); this.logger.Info(string.Format("Sending message to IOPub {0}", JsonSerializer.Serialize(executeInputMessage))); MessageSender.Send(executeInputMessage, ioPub); }
public void SendOutputMessageToIOPub(Message message, PublisherSocket ioPub, DisplayData data) { Dictionary<string,object> content = new Dictionary<string, object>(); content.Add("execution_count", this.executionCount); content.Add("data", data.Data); content.Add("metadata", data.MetaData); Message outputMessage = MessageBuilder.CreateMessage(MessageTypeValues.Output, JsonSerializer.Serialize(content), message.Header); this.logger.Info(string.Format("Sending message to IOPub {0}", JsonSerializer.Serialize(outputMessage))); MessageSender.Send(outputMessage, ioPub); }
public void SendMessageToIOPub(Message message, PublisherSocket ioPub, string statusValue) { Dictionary<string,string> content = new Dictionary<string, string>(); content.Add("execution_state", statusValue); Message ioPubMessage = MessageBuilder.CreateMessage(MessageTypeValues.Status, JsonSerializer.Serialize(content), message.Header); this.logger.Info(string.Format("Sending message to IOPub {0}", JsonSerializer.Serialize(ioPubMessage))); MessageSender.Send(ioPubMessage, ioPub); this.logger.Info("Message Sent"); }
private Message GetMessage() { Message message = new Message(); // Getting UUID message.UUID = this.server.ReceiveString(); this.logger.Info(message.UUID); // Getting Delimeter "<IDS|MSG>" this.server.ReceiveString(); // Getting Hmac message.HMac = this.server.ReceiveString(); this.logger.Info(message.HMac); // Getting Header string header = this.server.ReceiveString(); this.logger.Info(header); message.Header = JsonSerializer.Deserialize<Header>(header); // Getting parent header string parentHeader = this.server.ReceiveString(); this.logger.Info(parentHeader); message.ParentHeader = JsonSerializer.Deserialize<Header>(parentHeader); // Getting metadata string metadata = this.server.ReceiveString(); this.logger.Info(metadata); message.MetaData = JsonSerializer.Deserialize<Dictionary<string, object>>(metadata); // Getting content string content = this.server.ReceiveString(); this.logger.Info(content); message.Content = content; return message; }
public void HandleMessage(Message message, RouterSocket serverSocket, PublisherSocket ioPub) { CompleteRequest completeRequest = JsonSerializer.Deserialize<CompleteRequest>(message.Content); // TODO: Send reply }