WeinreTargetCommands.js
2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Generated by CoffeeScript 1.8.0
var WeinreClientEvents, WeinreTargetCommands, WeinreTargetEvents, channelManager, getCallbackChannel, serviceManager, utils;
utils = require('../utils');
channelManager = require('../channelManager');
serviceManager = require('../serviceManager');
WeinreClientEvents = serviceManager.get('WeinreClientEvents');
WeinreTargetEvents = serviceManager.get('WeinreTargetEvents');
module.exports = utils.registerClass(WeinreTargetCommands = (function() {
function WeinreTargetCommands() {}
WeinreTargetCommands.prototype.registerTarget = function(channel, url, callbackId) {
var clients;
channel.description.url = url;
clients = channelManager.getClientChannels(channel.id);
WeinreClientEvents.targetRegistered(clients, channel.description);
if (callbackId) {
return WeinreTargetEvents.sendCallback(channel, callbackId, channel.description);
}
};
WeinreTargetCommands.prototype.sendClientCallback = function(channel, clientCallbackId, args, callbackId) {
var callbackChannel;
callbackChannel = getCallbackChannel(clientCallbackId);
if (!callbackChannel) {
return main.warn("" + this.constructor.name + ".sendClientCallback() sent with invalid callbackId: " + clientCallbackId);
}
callbackChannel = channelManager.getChannel(callbackChannel);
if (!callbackChannel) {
return main.warn("" + this.constructor.name + ".sendClientCallback() unable to find channel : " + clientCallbackId);
}
WeinreClientEvents.sendCallback(callbackChannel, clientCallbackId, args);
if (callbackId) {
return WeinreTargetEvents.sendCallback(channel, callbackId, description);
}
};
WeinreTargetCommands.prototype.logDebug = function(channel, message, callbackId) {
utils.logVerbose("target " + channel.name + ": " + message);
if (callbackId) {
return WeinreTargetEvents.sendCallback(channel, callbackId, description);
}
};
WeinreTargetCommands.prototype.logInfo = function(channel, message, callbackId) {
utils.log("target " + channel.name + ": " + message);
if (callbackId) {
return WeinreTargetEvents.sendCallback(channel, callbackId, description);
}
};
WeinreTargetCommands.prototype.logWarning = function(channel, message, callbackId) {
utils.log("target " + channel.name + ": " + message);
if (callbackId) {
return WeinreTargetEvents.sendCallback(channel, callbackId, description);
}
};
WeinreTargetCommands.prototype.logError = function(channel, message, callbackId) {
utils.log("target " + channel.name + ": " + message);
if (callbackId) {
return WeinreTargetEvents.sendCallback(channel, callbackId, description);
}
};
return WeinreTargetCommands;
})());
getCallbackChannel = function(callbackId) {
callbackId = callbackId.toString();
return callbackId.split('::')[0];
};