public ZMessage Serilize(JupyterMessage msg) { var content1 = JsonConvert.SerializeObject(msg.header); var content2 = "{}"; var content3 = "{}"; var content4 = JsonConvert.SerializeObject(msg.content); var allText = content1 + content2 + content3 + content4; var signature = HashEncode(HashHMAC(StringEncode(Key), StringEncode(allText))); var result = new ZMessage(); result.Add(new ZFrame("<IDS|MSG>")); result.Add(new ZFrame(signature)); //HMAC-SHA256 signature result.Add(new ZFrame(content1)); result.Add(new ZFrame(content2)); result.Add(new ZFrame(content3)); result.Add(new ZFrame(content4)); return(result); }
//session.py msg function public JupyterMessage BuildMessage(JupyterMessage.Header.MsgType msgType, JupyterMessage.Content content) { var header = new JupyterMessage.Header() { msg_id = NewId(), username = Username, session = Id, date = DateTime.Now, msg_type = msgType, version = _protocolVersion }; var result = new JupyterMessage() { header = header, parent_header = null, metadata = null, content = content }; return(result); }