cdp-tunnel 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,8 +12,11 @@ var SpecialHandler = (function() {
|
|
|
12
12
|
function _getConnectionTag(ctx) {
|
|
13
13
|
var wm = ctx._wsManager;
|
|
14
14
|
var state = ctx._state;
|
|
15
|
-
//
|
|
16
|
-
if (state &&
|
|
15
|
+
// 端口池:按 clientId 查 connectionTag(端口号)
|
|
16
|
+
if (state && ctx.clientId && state.getTagForClient) {
|
|
17
|
+
var tag = state.getTagForClient(ctx.clientId);
|
|
18
|
+
if (tag) return tag;
|
|
19
|
+
}
|
|
17
20
|
return (wm && wm.config && wm.config.tag) || null;
|
|
18
21
|
}
|
|
19
22
|
|
|
@@ -2,6 +2,7 @@ function ConnectionState(connectionId, mode) {
|
|
|
2
2
|
this.connectionId = connectionId;
|
|
3
3
|
this.mode = mode || 'create';
|
|
4
4
|
this.connectionTag = null;
|
|
5
|
+
this.clientIdToTag = new Map();
|
|
5
6
|
this.ws = null;
|
|
6
7
|
this.reconnectTimer = null;
|
|
7
8
|
this._hasConnectedClient = false;
|
|
@@ -299,6 +300,14 @@ ConnectionState.prototype.clearPreExistingTabsForClient = function(clientId) {
|
|
|
299
300
|
});
|
|
300
301
|
};
|
|
301
302
|
|
|
303
|
+
ConnectionState.prototype.setTagForClient = function(clientId, tag) {
|
|
304
|
+
if (clientId && tag) this.clientIdToTag.set(clientId, tag);
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
ConnectionState.prototype.getTagForClient = function(clientId) {
|
|
308
|
+
return this.clientIdToTag.get(clientId) || null;
|
|
309
|
+
};
|
|
310
|
+
|
|
302
311
|
ConnectionState.prototype.addCDPClient = function(clientId, info) {
|
|
303
312
|
var exists = false;
|
|
304
313
|
for (var i = 0; i < this.cdpClients.length; i++) {
|
|
@@ -242,7 +242,7 @@ var WebSocketConnection = (function() {
|
|
|
242
242
|
self.state.setHasConnectedClient(true);
|
|
243
243
|
self.state.addCDPClient(message.clientId, message.clientId);
|
|
244
244
|
if (message.__connectionTag) {
|
|
245
|
-
self.state.
|
|
245
|
+
self.state.setTagForClient(message.clientId, message.__connectionTag);
|
|
246
246
|
}
|
|
247
247
|
self._createGroupForClient(message.clientId, message.__mode);
|
|
248
248
|
self._broadcastStateUpdate();
|
|
@@ -580,7 +580,7 @@ var WebSocketConnection = (function() {
|
|
|
580
580
|
var readyPromise = new Promise(function(resolve) { resolveGroupReady = resolve; });
|
|
581
581
|
self.state.setGroupCreationPromise(clientId, readyPromise);
|
|
582
582
|
|
|
583
|
-
var tag = self.state.
|
|
583
|
+
var tag = (self.state.getTagForClient ? self.state.getTagForClient(clientId) : null) || (self.config ? self.config.tag : null);
|
|
584
584
|
var baseName = CDPUtils.getGroupBaseName(clientId, tag, mode);
|
|
585
585
|
chrome.tabs.query({ currentWindow: true }, function(tabs) {
|
|
586
586
|
if (!tabs || tabs.length === 0) {
|
package/package.json
CHANGED