##// END OF EJS Templates
add message metadata to comm and kernel.send_shell_message
MinRK -
Show More
@@ -102,29 +102,29 b' var IPython = (function (IPython) {'
102 };
102 };
103
103
104 // methods for sending messages
104 // methods for sending messages
105 Comm.prototype.open = function (data, callbacks) {
105 Comm.prototype.open = function (data, callbacks, metadata) {
106 var content = {
106 var content = {
107 comm_id : this.comm_id,
107 comm_id : this.comm_id,
108 target_name : this.target_name,
108 target_name : this.target_name,
109 data : data || {},
109 data : data || {},
110 };
110 };
111 return this.kernel.send_shell_message("comm_open", content, callbacks);
111 return this.kernel.send_shell_message("comm_open", content, callbacks, metadata);
112 };
112 };
113
113
114 Comm.prototype.send = function (data, callbacks) {
114 Comm.prototype.send = function (data, callbacks, metadata) {
115 var content = {
115 var content = {
116 comm_id : this.comm_id,
116 comm_id : this.comm_id,
117 data : data || {},
117 data : data || {},
118 };
118 };
119 return this.kernel.send_shell_message("comm_msg", content, callbacks);
119 return this.kernel.send_shell_message("comm_msg", content, callbacks, metadata);
120 };
120 };
121
121
122 Comm.prototype.close = function (data, callbacks) {
122 Comm.prototype.close = function (data, callbacks, metadata) {
123 var content = {
123 var content = {
124 comm_id : this.comm_id,
124 comm_id : this.comm_id,
125 data : data || {},
125 data : data || {},
126 };
126 };
127 return this.kernel.send_shell_message("comm_close", content, callbacks);
127 return this.kernel.send_shell_message("comm_close", content, callbacks, metadata);
128 };
128 };
129
129
130 // methods for registering callbacks for incoming messages
130 // methods for registering callbacks for incoming messages
@@ -49,7 +49,7 b' var IPython = (function (IPython) {'
49 };
49 };
50
50
51
51
52 Kernel.prototype._get_msg = function (msg_type, content) {
52 Kernel.prototype._get_msg = function (msg_type, content, metadata) {
53 var msg = {
53 var msg = {
54 header : {
54 header : {
55 msg_id : utils.uuid(),
55 msg_id : utils.uuid(),
@@ -57,7 +57,7 b' var IPython = (function (IPython) {'
57 session : this.session_id,
57 session : this.session_id,
58 msg_type : msg_type
58 msg_type : msg_type
59 },
59 },
60 metadata : {},
60 metadata : metadata || {},
61 content : content,
61 content : content,
62 parent_header : {}
62 parent_header : {}
63 };
63 };
@@ -234,8 +234,8 b' var IPython = (function (IPython) {'
234 // Main public methods.
234 // Main public methods.
235
235
236 // send a message on the Kernel's shell channel
236 // send a message on the Kernel's shell channel
237 Kernel.prototype.send_shell_message = function (msg_type, content, callbacks) {
237 Kernel.prototype.send_shell_message = function (msg_type, content, callbacks, metadata) {
238 var msg = this._get_msg(msg_type, content);
238 var msg = this._get_msg(msg_type, content, metadata);
239 this.shell_channel.send(JSON.stringify(msg));
239 this.shell_channel.send(JSON.stringify(msg));
240 this.set_callbacks_for_msg(msg.header.msg_id, callbacks);
240 this.set_callbacks_for_msg(msg.header.msg_id, callbacks);
241 return msg.header.msg_id;
241 return msg.header.msg_id;
General Comments 0
You need to be logged in to leave comments. Login now