oorja 1.11.4 → 2.0.0
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.
- package/README.md +14 -52
- package/dist/commands/signout.d.ts +1 -1
- package/dist/commands/signout.js +4 -4
- package/dist/commands/teletype/index.d.ts +7 -6
- package/dist/commands/teletype/index.js +49 -47
- package/dist/lib/config.d.ts +7 -10
- package/dist/lib/config.js +29 -49
- package/dist/lib/{surya → connect}/index.d.ts +8 -8
- package/dist/lib/{surya → connect}/index.js +39 -36
- package/dist/lib/{surya → connect}/resources.js +2 -2
- package/dist/lib/{surya → connect}/types.d.ts +1 -3
- package/dist/lib/encryption.d.ts +2 -3
- package/dist/lib/encryption.js +6 -10
- package/dist/lib/oorja/client.d.ts +3 -0
- package/dist/lib/oorja/client.js +52 -0
- package/dist/lib/oorja/index.d.ts +7 -7
- package/dist/lib/oorja/index.js +40 -29
- package/dist/lib/oorja/preflight.d.ts +8 -8
- package/dist/lib/oorja/preflight.js +45 -41
- package/dist/lib/teletype/auxiliary.d.ts +2 -2
- package/dist/lib/teletype/auxiliary.js +5 -5
- package/dist/lib/teletype/index.d.ts +3 -4
- package/dist/lib/teletype/index.js +16 -16
- package/dist/lib/utils.js +5 -5
- package/oclif.manifest.json +11 -10
- package/package.json +22 -18
- package/dist/lib/surya/vendor/phoenix/ajax.d.ts +0 -8
- package/dist/lib/surya/vendor/phoenix/ajax.js +0 -82
- package/dist/lib/surya/vendor/phoenix/channel.d.ts +0 -154
- package/dist/lib/surya/vendor/phoenix/channel.js +0 -308
- package/dist/lib/surya/vendor/phoenix/constants.d.ts +0 -33
- package/dist/lib/surya/vendor/phoenix/constants.js +0 -29
- package/dist/lib/surya/vendor/phoenix/index.d.ts +0 -199
- package/dist/lib/surya/vendor/phoenix/index.js +0 -200
- package/dist/lib/surya/vendor/phoenix/longpoll.d.ts +0 -12
- package/dist/lib/surya/vendor/phoenix/longpoll.js +0 -126
- package/dist/lib/surya/vendor/phoenix/presence.d.ts +0 -44
- package/dist/lib/surya/vendor/phoenix/presence.js +0 -152
- package/dist/lib/surya/vendor/phoenix/push.d.ts +0 -57
- package/dist/lib/surya/vendor/phoenix/push.js +0 -122
- package/dist/lib/surya/vendor/phoenix/serializer.d.ts +0 -53
- package/dist/lib/surya/vendor/phoenix/serializer.js +0 -100
- package/dist/lib/surya/vendor/phoenix/socket.d.ts +0 -222
- package/dist/lib/surya/vendor/phoenix/socket.js +0 -541
- package/dist/lib/surya/vendor/phoenix/timer.d.ts +0 -25
- package/dist/lib/surya/vendor/phoenix/timer.js +0 -40
- package/dist/lib/surya/vendor/phoenix/utils.d.ts +0 -1
- package/dist/lib/surya/vendor/phoenix/utils.js +0 -11
- /package/dist/lib/{surya → connect}/errors.d.ts +0 -0
- /package/dist/lib/{surya → connect}/errors.js +0 -0
- /package/dist/lib/{surya → connect}/resources.d.ts +0 -0
- /package/dist/lib/{surya → connect}/types.js +0 -0
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
/**
|
|
3
|
-
* Initializes the Push
|
|
4
|
-
* @param {Channel} channel - The Channel
|
|
5
|
-
* @param {string} event - The event, for example `"phx_join"`
|
|
6
|
-
* @param {Object} payload - The payload, for example `{user_id: 123}`
|
|
7
|
-
* @param {number} timeout - The push timeout in milliseconds
|
|
8
|
-
*/
|
|
9
|
-
export default class Push {
|
|
10
|
-
constructor(channel, event, payload, timeout) {
|
|
11
|
-
this.channel = channel;
|
|
12
|
-
this.event = event;
|
|
13
|
-
this.payload = payload || function () { return {}; };
|
|
14
|
-
this.receivedResp = null;
|
|
15
|
-
this.timeout = timeout;
|
|
16
|
-
this.timeoutTimer = null;
|
|
17
|
-
this.recHooks = [];
|
|
18
|
-
this.sent = false;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @param {number} timeout
|
|
23
|
-
*/
|
|
24
|
-
resend(timeout) {
|
|
25
|
-
this.timeout = timeout;
|
|
26
|
-
this.reset();
|
|
27
|
-
this.send();
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
*/
|
|
32
|
-
send() {
|
|
33
|
-
if (this.hasReceived("timeout")) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
this.startTimeout();
|
|
37
|
-
this.sent = true;
|
|
38
|
-
this.channel.socket.push({
|
|
39
|
-
topic: this.channel.topic,
|
|
40
|
-
event: this.event,
|
|
41
|
-
payload: this.payload(),
|
|
42
|
-
ref: this.ref,
|
|
43
|
-
join_ref: this.channel.joinRef()
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
* @param {*} status
|
|
49
|
-
* @param {*} callback
|
|
50
|
-
*/
|
|
51
|
-
receive(status, callback) {
|
|
52
|
-
if (this.hasReceived(status)) {
|
|
53
|
-
callback(this.receivedResp.response);
|
|
54
|
-
}
|
|
55
|
-
this.recHooks.push({ status, callback });
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* @private
|
|
60
|
-
*/
|
|
61
|
-
reset() {
|
|
62
|
-
this.cancelRefEvent();
|
|
63
|
-
this.ref = null;
|
|
64
|
-
this.refEvent = null;
|
|
65
|
-
this.receivedResp = null;
|
|
66
|
-
this.sent = false;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* @private
|
|
70
|
-
*/
|
|
71
|
-
matchReceive({ status, response, _ref }) {
|
|
72
|
-
this.recHooks.filter(h => h.status === status)
|
|
73
|
-
.forEach(h => h.callback(response));
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* @private
|
|
77
|
-
*/
|
|
78
|
-
cancelRefEvent() {
|
|
79
|
-
if (!this.refEvent) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
this.channel.off(this.refEvent);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* @private
|
|
86
|
-
*/
|
|
87
|
-
cancelTimeout() {
|
|
88
|
-
clearTimeout(this.timeoutTimer);
|
|
89
|
-
this.timeoutTimer = null;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* @private
|
|
93
|
-
*/
|
|
94
|
-
startTimeout() {
|
|
95
|
-
if (this.timeoutTimer) {
|
|
96
|
-
this.cancelTimeout();
|
|
97
|
-
}
|
|
98
|
-
this.ref = this.channel.socket.makeRef();
|
|
99
|
-
this.refEvent = this.channel.replyEventName(this.ref);
|
|
100
|
-
this.channel.on(this.refEvent, payload => {
|
|
101
|
-
this.cancelRefEvent();
|
|
102
|
-
this.cancelTimeout();
|
|
103
|
-
this.receivedResp = payload;
|
|
104
|
-
this.matchReceive(payload);
|
|
105
|
-
});
|
|
106
|
-
this.timeoutTimer = setTimeout(() => {
|
|
107
|
-
this.trigger("timeout", {});
|
|
108
|
-
}, this.timeout);
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* @private
|
|
112
|
-
*/
|
|
113
|
-
hasReceived(status) {
|
|
114
|
-
return this.receivedResp && this.receivedResp.status === status;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* @private
|
|
118
|
-
*/
|
|
119
|
-
trigger(status, response) {
|
|
120
|
-
this.channel.trigger(this.refEvent, { status, response });
|
|
121
|
-
}
|
|
122
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
HEADER_LENGTH: number;
|
|
3
|
-
META_LENGTH: number;
|
|
4
|
-
KINDS: {
|
|
5
|
-
push: number;
|
|
6
|
-
reply: number;
|
|
7
|
-
broadcast: number;
|
|
8
|
-
};
|
|
9
|
-
encode(msg: any, callback: any): any;
|
|
10
|
-
decode(rawPayload: any, callback: any): any;
|
|
11
|
-
binaryEncode(message: any): ArrayBufferLike;
|
|
12
|
-
binaryDecode(buffer: any): {
|
|
13
|
-
join_ref: any;
|
|
14
|
-
ref: null;
|
|
15
|
-
topic: any;
|
|
16
|
-
event: any;
|
|
17
|
-
payload: any;
|
|
18
|
-
} | {
|
|
19
|
-
join_ref: any;
|
|
20
|
-
ref: any;
|
|
21
|
-
topic: any;
|
|
22
|
-
event: string;
|
|
23
|
-
payload: {
|
|
24
|
-
status: any;
|
|
25
|
-
response: any;
|
|
26
|
-
};
|
|
27
|
-
} | undefined;
|
|
28
|
-
decodePush(buffer: any, view: any, decoder: any): {
|
|
29
|
-
join_ref: any;
|
|
30
|
-
ref: null;
|
|
31
|
-
topic: any;
|
|
32
|
-
event: any;
|
|
33
|
-
payload: any;
|
|
34
|
-
};
|
|
35
|
-
decodeReply(buffer: any, view: any, decoder: any): {
|
|
36
|
-
join_ref: any;
|
|
37
|
-
ref: any;
|
|
38
|
-
topic: any;
|
|
39
|
-
event: string;
|
|
40
|
-
payload: {
|
|
41
|
-
status: any;
|
|
42
|
-
response: any;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
decodeBroadcast(buffer: any, view: any, decoder: any): {
|
|
46
|
-
join_ref: null;
|
|
47
|
-
ref: null;
|
|
48
|
-
topic: any;
|
|
49
|
-
event: any;
|
|
50
|
-
payload: any;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
export default _default;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
/* The default serializer for encoding and decoding messages */
|
|
3
|
-
import { CHANNEL_EVENTS } from "./constants.js";
|
|
4
|
-
export default {
|
|
5
|
-
HEADER_LENGTH: 1,
|
|
6
|
-
META_LENGTH: 4,
|
|
7
|
-
KINDS: { push: 0, reply: 1, broadcast: 2 },
|
|
8
|
-
encode(msg, callback) {
|
|
9
|
-
if (msg.payload.constructor === ArrayBuffer) {
|
|
10
|
-
return callback(this.binaryEncode(msg));
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
let payload = [msg.join_ref, msg.ref, msg.topic, msg.event, msg.payload];
|
|
14
|
-
return callback(JSON.stringify(payload));
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
decode(rawPayload, callback) {
|
|
18
|
-
if (rawPayload.constructor === ArrayBuffer) {
|
|
19
|
-
return callback(this.binaryDecode(rawPayload));
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
let [join_ref, ref, topic, event, payload] = JSON.parse(rawPayload);
|
|
23
|
-
return callback({ join_ref, ref, topic, event, payload });
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
// private
|
|
27
|
-
binaryEncode(message) {
|
|
28
|
-
let { join_ref, ref, event, topic, payload } = message;
|
|
29
|
-
let metaLength = this.META_LENGTH + join_ref.length + ref.length + topic.length + event.length;
|
|
30
|
-
let header = new ArrayBuffer(this.HEADER_LENGTH + metaLength);
|
|
31
|
-
let view = new DataView(header);
|
|
32
|
-
let offset = 0;
|
|
33
|
-
view.setUint8(offset++, this.KINDS.push); // kind
|
|
34
|
-
view.setUint8(offset++, join_ref.length);
|
|
35
|
-
view.setUint8(offset++, ref.length);
|
|
36
|
-
view.setUint8(offset++, topic.length);
|
|
37
|
-
view.setUint8(offset++, event.length);
|
|
38
|
-
Array.from(join_ref, char => view.setUint8(offset++, char.charCodeAt(0)));
|
|
39
|
-
Array.from(ref, char => view.setUint8(offset++, char.charCodeAt(0)));
|
|
40
|
-
Array.from(topic, char => view.setUint8(offset++, char.charCodeAt(0)));
|
|
41
|
-
Array.from(event, char => view.setUint8(offset++, char.charCodeAt(0)));
|
|
42
|
-
var combined = new Uint8Array(header.byteLength + payload.byteLength);
|
|
43
|
-
combined.set(new Uint8Array(header), 0);
|
|
44
|
-
combined.set(new Uint8Array(payload), header.byteLength);
|
|
45
|
-
return combined.buffer;
|
|
46
|
-
},
|
|
47
|
-
binaryDecode(buffer) {
|
|
48
|
-
let view = new DataView(buffer);
|
|
49
|
-
let kind = view.getUint8(0);
|
|
50
|
-
let decoder = new TextDecoder();
|
|
51
|
-
switch (kind) {
|
|
52
|
-
case this.KINDS.push: return this.decodePush(buffer, view, decoder);
|
|
53
|
-
case this.KINDS.reply: return this.decodeReply(buffer, view, decoder);
|
|
54
|
-
case this.KINDS.broadcast: return this.decodeBroadcast(buffer, view, decoder);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
decodePush(buffer, view, decoder) {
|
|
58
|
-
let joinRefSize = view.getUint8(1);
|
|
59
|
-
let topicSize = view.getUint8(2);
|
|
60
|
-
let eventSize = view.getUint8(3);
|
|
61
|
-
let offset = this.HEADER_LENGTH + this.META_LENGTH - 1; // pushes have no ref
|
|
62
|
-
let joinRef = decoder.decode(buffer.slice(offset, offset + joinRefSize));
|
|
63
|
-
offset = offset + joinRefSize;
|
|
64
|
-
let topic = decoder.decode(buffer.slice(offset, offset + topicSize));
|
|
65
|
-
offset = offset + topicSize;
|
|
66
|
-
let event = decoder.decode(buffer.slice(offset, offset + eventSize));
|
|
67
|
-
offset = offset + eventSize;
|
|
68
|
-
let data = buffer.slice(offset, buffer.byteLength);
|
|
69
|
-
return { join_ref: joinRef, ref: null, topic: topic, event: event, payload: data };
|
|
70
|
-
},
|
|
71
|
-
decodeReply(buffer, view, decoder) {
|
|
72
|
-
let joinRefSize = view.getUint8(1);
|
|
73
|
-
let refSize = view.getUint8(2);
|
|
74
|
-
let topicSize = view.getUint8(3);
|
|
75
|
-
let eventSize = view.getUint8(4);
|
|
76
|
-
let offset = this.HEADER_LENGTH + this.META_LENGTH;
|
|
77
|
-
let joinRef = decoder.decode(buffer.slice(offset, offset + joinRefSize));
|
|
78
|
-
offset = offset + joinRefSize;
|
|
79
|
-
let ref = decoder.decode(buffer.slice(offset, offset + refSize));
|
|
80
|
-
offset = offset + refSize;
|
|
81
|
-
let topic = decoder.decode(buffer.slice(offset, offset + topicSize));
|
|
82
|
-
offset = offset + topicSize;
|
|
83
|
-
let event = decoder.decode(buffer.slice(offset, offset + eventSize));
|
|
84
|
-
offset = offset + eventSize;
|
|
85
|
-
let data = buffer.slice(offset, buffer.byteLength);
|
|
86
|
-
let payload = { status: event, response: data };
|
|
87
|
-
return { join_ref: joinRef, ref: ref, topic: topic, event: CHANNEL_EVENTS.reply, payload: payload };
|
|
88
|
-
},
|
|
89
|
-
decodeBroadcast(buffer, view, decoder) {
|
|
90
|
-
let topicSize = view.getUint8(1);
|
|
91
|
-
let eventSize = view.getUint8(2);
|
|
92
|
-
let offset = this.HEADER_LENGTH + 2;
|
|
93
|
-
let topic = decoder.decode(buffer.slice(offset, offset + topicSize));
|
|
94
|
-
offset = offset + topicSize;
|
|
95
|
-
let event = decoder.decode(buffer.slice(offset, offset + eventSize));
|
|
96
|
-
offset = offset + eventSize;
|
|
97
|
-
let data = buffer.slice(offset, buffer.byteLength);
|
|
98
|
-
return { join_ref: null, ref: null, topic: topic, event: event, payload: data };
|
|
99
|
-
}
|
|
100
|
-
};
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import Channel from "./channel.js";
|
|
2
|
-
import LongPoll from "./longpoll.js";
|
|
3
|
-
/** Initializes the Socket *
|
|
4
|
-
*
|
|
5
|
-
* For IE8 support use an ES5-shim (https://github.com/es-shims/es5-shim)
|
|
6
|
-
*
|
|
7
|
-
* @param {string} endPoint - The string WebSocket endpoint, ie, `"ws://example.com/socket"`,
|
|
8
|
-
* `"wss://example.com"`
|
|
9
|
-
* `"/socket"` (inherited host & protocol)
|
|
10
|
-
* @param {Object} [opts] - Optional configuration
|
|
11
|
-
* @param {Function} [opts.transport] - The Websocket Transport, for example WebSocket or Phoenix.LongPoll.
|
|
12
|
-
*
|
|
13
|
-
* Defaults to WebSocket with automatic LongPoll fallback.
|
|
14
|
-
* @param {Function} [opts.encode] - The function to encode outgoing messages.
|
|
15
|
-
*
|
|
16
|
-
* Defaults to JSON encoder.
|
|
17
|
-
*
|
|
18
|
-
* @param {Function} [opts.decode] - The function to decode incoming messages.
|
|
19
|
-
*
|
|
20
|
-
* Defaults to JSON:
|
|
21
|
-
*
|
|
22
|
-
* ```javascript
|
|
23
|
-
* (payload, callback) => callback(JSON.parse(payload))
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @param {number} [opts.timeout] - The default timeout in milliseconds to trigger push timeouts.
|
|
27
|
-
*
|
|
28
|
-
* Defaults `DEFAULT_TIMEOUT`
|
|
29
|
-
* @param {number} [opts.heartbeatIntervalMs] - The millisec interval to send a heartbeat message
|
|
30
|
-
* @param {number} [opts.reconnectAfterMs] - The optional function that returns the millisec
|
|
31
|
-
* socket reconnect interval.
|
|
32
|
-
*
|
|
33
|
-
* Defaults to stepped backoff of:
|
|
34
|
-
*
|
|
35
|
-
* ```javascript
|
|
36
|
-
* function(tries){
|
|
37
|
-
* return [10, 50, 100, 150, 200, 250, 500, 1000, 2000][tries - 1] || 5000
|
|
38
|
-
* }
|
|
39
|
-
* ````
|
|
40
|
-
*
|
|
41
|
-
* @param {number} [opts.rejoinAfterMs] - The optional function that returns the millisec
|
|
42
|
-
* rejoin interval for individual channels.
|
|
43
|
-
*
|
|
44
|
-
* ```javascript
|
|
45
|
-
* function(tries){
|
|
46
|
-
* return [1000, 2000, 5000][tries - 1] || 10000
|
|
47
|
-
* }
|
|
48
|
-
* ````
|
|
49
|
-
*
|
|
50
|
-
* @param {Function} [opts.logger] - The optional function for specialized logging, ie:
|
|
51
|
-
*
|
|
52
|
-
* ```javascript
|
|
53
|
-
* function(kind, msg, data) {
|
|
54
|
-
* console.log(`${kind}: ${msg}`, data)
|
|
55
|
-
* }
|
|
56
|
-
* ```
|
|
57
|
-
*
|
|
58
|
-
* @param {number} [opts.longpollerTimeout] - The maximum timeout of a long poll AJAX request.
|
|
59
|
-
*
|
|
60
|
-
* Defaults to 20s (double the server long poll timer).
|
|
61
|
-
*
|
|
62
|
-
* @param {(Object|function)} [opts.params] - The optional params to pass when connecting
|
|
63
|
-
* @param {string} [opts.binaryType] - The binary type to use for binary WebSocket frames.
|
|
64
|
-
*
|
|
65
|
-
* Defaults to "arraybuffer"
|
|
66
|
-
*
|
|
67
|
-
* @param {vsn} [opts.vsn] - The serializer's protocol version to send on connect.
|
|
68
|
-
*
|
|
69
|
-
* Defaults to DEFAULT_VSN.
|
|
70
|
-
*/
|
|
71
|
-
export default class Socket {
|
|
72
|
-
constructor(endPoint: any, opts?: {});
|
|
73
|
-
/**
|
|
74
|
-
* Returns the LongPoll transport reference
|
|
75
|
-
*/
|
|
76
|
-
getLongPollTransport(): typeof LongPoll;
|
|
77
|
-
/**
|
|
78
|
-
* Disconnects and replaces the active transport
|
|
79
|
-
*
|
|
80
|
-
* @param {Function} newTransport - The new transport class to instantiate
|
|
81
|
-
*
|
|
82
|
-
*/
|
|
83
|
-
replaceTransport(newTransport: any): void;
|
|
84
|
-
/**
|
|
85
|
-
* Returns the socket protocol
|
|
86
|
-
*
|
|
87
|
-
* @returns {string}
|
|
88
|
-
*/
|
|
89
|
-
protocol(): "wss" | "ws";
|
|
90
|
-
/**
|
|
91
|
-
* The fully qualified socket url
|
|
92
|
-
*
|
|
93
|
-
* @returns {string}
|
|
94
|
-
*/
|
|
95
|
-
endPointURL(): any;
|
|
96
|
-
/**
|
|
97
|
-
* Disconnects the socket
|
|
98
|
-
*
|
|
99
|
-
* See https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes for valid status codes.
|
|
100
|
-
*
|
|
101
|
-
* @param {Function} callback - Optional callback which is called after socket is disconnected.
|
|
102
|
-
* @param {integer} code - A status code for disconnection (Optional).
|
|
103
|
-
* @param {string} reason - A textual description of the reason to disconnect. (Optional)
|
|
104
|
-
*/
|
|
105
|
-
disconnect(callback: any, code: any, reason: any): void;
|
|
106
|
-
/**
|
|
107
|
-
*
|
|
108
|
-
* @param {Object} params - The params to send when connecting, for example `{user_id: userToken}`
|
|
109
|
-
*
|
|
110
|
-
* Passing params to connect is deprecated; pass them in the Socket constructor instead:
|
|
111
|
-
* `new Socket("/socket", {params: {user_id: userToken}})`.
|
|
112
|
-
*/
|
|
113
|
-
connect(params: any): void;
|
|
114
|
-
/**
|
|
115
|
-
* Logs the message. Override `this.logger` for specialized logging. noops by default
|
|
116
|
-
* @param {string} kind
|
|
117
|
-
* @param {string} msg
|
|
118
|
-
* @param {Object} data
|
|
119
|
-
*/
|
|
120
|
-
log(kind: any, msg: any, data: any): void;
|
|
121
|
-
/**
|
|
122
|
-
* Returns true if a logger has been set on this socket.
|
|
123
|
-
*/
|
|
124
|
-
hasLogger(): boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Registers callbacks for connection open events
|
|
127
|
-
*
|
|
128
|
-
* @example socket.onOpen(function(){ console.info("the socket was opened") })
|
|
129
|
-
*
|
|
130
|
-
* @param {Function} callback
|
|
131
|
-
*/
|
|
132
|
-
onOpen(callback: any): any;
|
|
133
|
-
/**
|
|
134
|
-
* Registers callbacks for connection close events
|
|
135
|
-
* @param {Function} callback
|
|
136
|
-
*/
|
|
137
|
-
onClose(callback: any): any;
|
|
138
|
-
/**
|
|
139
|
-
* Registers callbacks for connection error events
|
|
140
|
-
*
|
|
141
|
-
* @example socket.onError(function(error){ alert("An error occurred") })
|
|
142
|
-
*
|
|
143
|
-
* @param {Function} callback
|
|
144
|
-
*/
|
|
145
|
-
onError(callback: any): any;
|
|
146
|
-
/**
|
|
147
|
-
* Registers callbacks for connection message events
|
|
148
|
-
* @param {Function} callback
|
|
149
|
-
*/
|
|
150
|
-
onMessage(callback: any): any;
|
|
151
|
-
/**
|
|
152
|
-
* Pings the server and invokes the callback with the RTT in milliseconds
|
|
153
|
-
* @param {Function} callback
|
|
154
|
-
*
|
|
155
|
-
* Returns true if the ping was pushed or false if unable to be pushed.
|
|
156
|
-
*/
|
|
157
|
-
ping(callback: any): boolean;
|
|
158
|
-
/**
|
|
159
|
-
* @private
|
|
160
|
-
*/
|
|
161
|
-
clearHeartbeats(): void;
|
|
162
|
-
onConnOpen(): void;
|
|
163
|
-
/**
|
|
164
|
-
* @private
|
|
165
|
-
*/
|
|
166
|
-
heartbeatTimeout(): void;
|
|
167
|
-
resetHeartbeat(): void;
|
|
168
|
-
teardown(callback: any, code: any, reason: any): any;
|
|
169
|
-
waitForBufferDone(callback: any, tries?: number): void;
|
|
170
|
-
waitForSocketClosed(callback: any, tries?: number): void;
|
|
171
|
-
onConnClose(event: any): void;
|
|
172
|
-
/**
|
|
173
|
-
* @private
|
|
174
|
-
*/
|
|
175
|
-
onConnError(error: any): void;
|
|
176
|
-
/**
|
|
177
|
-
* @private
|
|
178
|
-
*/
|
|
179
|
-
triggerChanError(): void;
|
|
180
|
-
/**
|
|
181
|
-
* @returns {string}
|
|
182
|
-
*/
|
|
183
|
-
connectionState(): "open" | "closed" | "connecting" | "closing";
|
|
184
|
-
/**
|
|
185
|
-
* @returns {boolean}
|
|
186
|
-
*/
|
|
187
|
-
isConnected(): boolean;
|
|
188
|
-
/**
|
|
189
|
-
* @private
|
|
190
|
-
*
|
|
191
|
-
* @param {Channel}
|
|
192
|
-
*/
|
|
193
|
-
remove(channel: any): void;
|
|
194
|
-
/**
|
|
195
|
-
* Removes `onOpen`, `onClose`, `onError,` and `onMessage` registrations.
|
|
196
|
-
*
|
|
197
|
-
* @param {refs} - list of refs returned by calls to
|
|
198
|
-
* `onOpen`, `onClose`, `onError,` and `onMessage`
|
|
199
|
-
*/
|
|
200
|
-
off(refs: any): void;
|
|
201
|
-
/**
|
|
202
|
-
* Initiates a new channel for the given topic
|
|
203
|
-
*
|
|
204
|
-
* @param {string} topic
|
|
205
|
-
* @param {Object} chanParams - Parameters for the channel
|
|
206
|
-
* @returns {Channel}
|
|
207
|
-
*/
|
|
208
|
-
channel(topic: any, chanParams?: {}): Channel;
|
|
209
|
-
/**
|
|
210
|
-
* @param {Object} data
|
|
211
|
-
*/
|
|
212
|
-
push(data: any): void;
|
|
213
|
-
/**
|
|
214
|
-
* Return the next message ref, accounting for overflows
|
|
215
|
-
* @returns {string}
|
|
216
|
-
*/
|
|
217
|
-
makeRef(): any;
|
|
218
|
-
sendHeartbeat(): void;
|
|
219
|
-
flushSendBuffer(): void;
|
|
220
|
-
onConnMessage(rawMessage: any): void;
|
|
221
|
-
leaveOpenTopic(topic: any): void;
|
|
222
|
-
}
|