-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Replace socket.io-client #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5b879be
24828db
67f6ee3
e83367d
f82e685
ee02b81
ca3335c
19e57b7
176a79b
3144260
cd01dbb
698e989
0d34757
296e94b
91c24d0
d20f3b3
c91be00
e6468ac
d6b1db0
476cc63
c834a91
b685485
5c739b5
8da3169
46a30bc
0f4e38d
9111ff6
4b37c54
5cdbb8f
b5aab44
840ca66
1d4d94d
4ba1185
64b72d5
3b6184b
c6dd1ce
3220751
353451b
fd7068e
9ca5847
7e82176
1ab12d8
cae48f4
cc00cdf
9bb84b0
04feff1
96ae6bf
453ba50
f733d34
230b9fc
7c9fff7
3bf55f4
3f4f3e8
a7834e5
3491353
f9a0bd8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
lib/ | ||
socket.io-websocket-only.js | ||
doc/resource | ||
coverage/ | ||
build/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,3 +59,4 @@ package.tgz | |
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
.DS_Store |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// :copyright: Copyright (c) 2016 ftrack | ||
import { v4 as uuidV4 } from "uuid"; | ||
import loglevel from "loglevel"; | ||
import * as io from "./socket.io-websocket-only.js"; | ||
import io from "./simple_socketio.js"; | ||
import { Event } from "./event.js"; | ||
import { | ||
EventServerConnectionTimeoutError, | ||
|
@@ -72,11 +72,11 @@ export type EventPayload = | |
| UpdateEventPayload; | ||
|
||
export interface EventSource { | ||
clientToken: string; | ||
clientToken?: string; | ||
applicationId: string; | ||
user: { | ||
username: string; | ||
id: string; | ||
id?: string; | ||
}; | ||
id: string; | ||
} | ||
|
@@ -132,7 +132,7 @@ export class EventHub { | |
}; | ||
private _unsentEvents: ConnectionCallback[]; | ||
private _subscribers: Subscriber[]; | ||
private _socketIo: io.SocketIO | null; | ||
private _socketIo: io | null; | ||
|
||
/** | ||
* Construct EventHub instance with API credentials. | ||
|
@@ -177,17 +177,7 @@ export class EventHub { | |
|
||
/** Connect to the event server. */ | ||
connect(): void { | ||
this._socketIo = io.connect(this._serverUrl, { | ||
"max reconnection attempts": Infinity, | ||
"reconnection limit": 10000, | ||
"reconnection delay": 5000, | ||
transports: ["websocket"], | ||
query: new URLSearchParams({ | ||
api_user: this._apiUser, | ||
api_key: this._apiKey, | ||
}).toString(), | ||
}); | ||
|
||
this._socketIo = io.connect(this._serverUrl, this._apiUser, this._apiKey); | ||
this._socketIo.on("connect", this._onSocketConnected); | ||
this._socketIo.on("ftrack.event", this._handle); | ||
} | ||
|
@@ -197,7 +187,7 @@ export class EventHub { | |
* @return {Boolean} | ||
*/ | ||
isConnected(): boolean { | ||
return (this._socketIo && this._socketIo.socket.connected) || false; | ||
return this._socketIo?.isConnected() || false; | ||
} | ||
|
||
/** | ||
|
@@ -247,7 +237,7 @@ export class EventHub { | |
* | ||
* If timeout is non-zero, the promise will be rejected if the event is not | ||
* sent before the timeout is reached. Should be specified as seconds and | ||
* will default to 10. | ||
* will default to 30. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this a breaking change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was simply my noticing that the comment was incorrect. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah okay. All good then! |
||
* | ||
* @param {Event} event Event instance to publish | ||
* @param {Function} [options.onReply] Function to be invoked when a reply | ||
|
@@ -368,7 +358,7 @@ export class EventHub { | |
// Force reconnect socket if not automatically reconnected. This | ||
// happens for example in Adobe After Effects when rendering a | ||
// sequence takes longer than ~30s and the JS thread is blocked. | ||
this._socketIo.socket.reconnect(); | ||
this._socketIo.reconnect(); | ||
} | ||
} else { | ||
callback(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove unrelated dependency upgrades and make them in a separate PR