Show More
@@ -40,6 +40,15 b' var IPython = (function (IPython) {' | |||||
40 | } |
|
40 | } | |
41 | }; |
|
41 | }; | |
42 |
|
42 | |||
|
43 | CommManager.prototype.new_comm = function (target_name, data, callbacks, metadata, comm_id) { | |||
|
44 | // Create a new Comm, register it, and open its Kernel-side counterpart | |||
|
45 | // Mimics the auto-registration in `Comm.__init__` in the IPython Comm | |||
|
46 | var comm = new Comm(target_name, comm_id); | |||
|
47 | this.register_comm(comm); | |||
|
48 | comm.open(data, callbacks, metadata); | |||
|
49 | return comm; | |||
|
50 | }; | |||
|
51 | ||||
43 | CommManager.prototype.register_target = function (target_name, f) { |
|
52 | CommManager.prototype.register_target = function (target_name, f) { | |
44 | // Register a target function for a given target name |
|
53 | // Register a target function for a given target name | |
45 | this.targets[target_name] = f; |
|
54 | this.targets[target_name] = f; | |
@@ -72,7 +81,7 b' var IPython = (function (IPython) {' | |||||
72 | console.log("Available targets are: ", this.targets); |
|
81 | console.log("Available targets are: ", this.targets); | |
73 | return; |
|
82 | return; | |
74 | } |
|
83 | } | |
75 | var comm = new Comm(content.comm_id); |
|
84 | var comm = new Comm(content.target_name, content.comm_id); | |
76 | this.register_comm(comm); |
|
85 | this.register_comm(comm); | |
77 | try { |
|
86 | try { | |
78 | f(comm, msg); |
|
87 | f(comm, msg); | |
@@ -114,9 +123,9 b' var IPython = (function (IPython) {' | |||||
114 | // Comm base class |
|
123 | // Comm base class | |
115 | //----------------------------------------------------------------------- |
|
124 | //----------------------------------------------------------------------- | |
116 |
|
125 | |||
117 |
var Comm = function ( |
|
126 | var Comm = function (target_name, comm_id) { | |
118 | this.comm_id = comm_id || new IPython.utils.uuid(); |
|
|||
119 | this.target_name = target_name; |
|
127 | this.target_name = target_name; | |
|
128 | this.comm_id = comm_id || IPython.utils.uuid(); | |||
120 | this._msg_callback = this._close_callback = null; |
|
129 | this._msg_callback = this._close_callback = null; | |
121 | }; |
|
130 | }; | |
122 |
|
131 |
General Comments 0
You need to be logged in to leave comments.
Login now