s/target/target_name

This commit is contained in:
MinRK 2013-09-25 11:02:21 -07:00
parent f833b1ca03
commit aa0387a647

View File

@ -24,7 +24,7 @@ var IPython = (function (IPython) {
var CommManager = function (kernel) { var CommManager = function (kernel) {
this.comms = {}; this.comms = {};
this.targets = {comm : Comm}; this.targets = {};
if (kernel !== undefined) { if (kernel !== undefined) {
this.init_kernel(kernel); this.init_kernel(kernel);
} }
@ -40,9 +40,9 @@ var IPython = (function (IPython) {
} }
}; };
CommManager.prototype.register_target = function (target, constructor) { CommManager.prototype.register_target = function (target_name, f) {
// Register a constructor for a given target key // Register a target function for a given target name
this.targets[target] = constructor; this.targets[target_name] = f;
}; };
CommManager.prototype.register_comm = function (comm) { CommManager.prototype.register_comm = function (comm) {
@ -61,9 +61,9 @@ var IPython = (function (IPython) {
CommManager.prototype.comm_open = function (msg) { CommManager.prototype.comm_open = function (msg) {
var content = msg.content; var content = msg.content;
var callback = this.targets[content.target]; var callback = this.targets[content.target_name];
if (callback === undefined) { if (callback === undefined) {
console.log("No such target registered: ", content.target); console.log("No such target registered: ", content.target_name);
console.log("Available targets are: ", this.targets); console.log("Available targets are: ", this.targets);
return; return;
} }
@ -96,9 +96,9 @@ var IPython = (function (IPython) {
// Comm base class // Comm base class
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
var Comm = function (comm_id, target) { var Comm = function (comm_id, target_name) {
this.comm_id = comm_id || new IPython.utils.uuid(); this.comm_id = comm_id || new IPython.utils.uuid();
this.target = target || 'comm'; this.target_name = target_name;
this._msg_callback = this._open_callback = this._close_callback = null; this._msg_callback = this._open_callback = this._close_callback = null;
}; };
@ -106,7 +106,7 @@ var IPython = (function (IPython) {
Comm.prototype.open = function (data, callbacks) { Comm.prototype.open = function (data, callbacks) {
var content = { var content = {
comm_id : this.comm_id, comm_id : this.comm_id,
target : this.target, target_name : this.target_name,
data : data || {}, data : data || {},
}; };
return this.kernel.send_shell_message("comm_open", content, callbacks); return this.kernel.send_shell_message("comm_open", content, callbacks);