##// END OF EJS Templates
allow metadata in Kernel-side Comm messages.
MinRK -
Show More
@@ -63,11 +63,13 b' class Comm(LoggingConfigurable):'
63 63 # I am primary, open my peer.
64 64 self.open(data)
65 65
66 def _publish_msg(self, msg_type, data=None, **keys):
66 def _publish_msg(self, msg_type, data=None, metadata=None, **keys):
67 67 """Helper for sending a comm message on IOPub"""
68 68 data = {} if data is None else data
69 metadata = {} if metadata is None else metadata
69 70 self.session.send(self.iopub_socket, msg_type,
70 71 dict(data=data, comm_id=self.comm_id, **keys),
72 metadata=metadata,
71 73 parent=self.shell.get_parent(),
72 74 ident=self.topic,
73 75 )
@@ -78,25 +80,25 b' class Comm(LoggingConfigurable):'
78 80
79 81 # publishing messages
80 82
81 def open(self, data=None):
83 def open(self, data=None, metadata=None):
82 84 """Open the frontend-side version of this comm"""
83 85 if data is None:
84 86 data = self._open_data
85 self._publish_msg('comm_open', data, target_name=self.target_name)
87 self._publish_msg('comm_open', data, metadata, target_name=self.target_name)
86 88
87 def close(self, data=None):
89 def close(self, data=None, metadata=None):
88 90 """Close the frontend-side version of this comm"""
89 91 if self._closed:
90 92 # only close once
91 93 return
92 94 if data is None:
93 95 data = self._close_data
94 self._publish_msg('comm_close', data)
96 self._publish_msg('comm_close', data, metadata)
95 97 self._closed = True
96 98
97 def send(self, data=None):
99 def send(self, data=None, metadata=None):
98 100 """Send a message to the frontend-side version of this comm"""
99 self._publish_msg('comm_msg', data)
101 self._publish_msg('comm_msg', data, metadata)
100 102
101 103 # registering callbacks
102 104
General Comments 0
You need to be logged in to leave comments. Login now