Skip to content

Commit

Permalink
fix: persist nodeId between WS reconnections
Browse files Browse the repository at this point in the history
  • Loading branch information
savokr committed Mar 31, 2024
1 parent 83aac06 commit 5fed471
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client-package/src/SessionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@ export class SessionManager {
private _tasksManager: TasksManager;
private _inferenceServer: InferenceServer;
private _ws?: WebSocket | WebSocketNode;

private _nodeId: string;

constructor(options: SessionManagerOptions) {
const { backendServerWebSocketUrl, inferenceServerUrl, inferenceServerType } = options;

this._inferenceServerUrl = inferenceServerUrl;
this._backendServerWebSocketUrl = backendServerWebSocketUrl;

this._nodeId = uuidv4();

switch (inferenceServerType) {
case 'automatic':
this._inferenceServer = new AutomaticInferenceServer({ inferenceServerUrl });
Expand Down Expand Up @@ -102,7 +105,7 @@ export class SessionManager {
const { _ws: ws } = this;

const onSocketOpen = () => {
ws.send(JSON.stringify({ type: 'register', node_id: uuidv4() }));
ws.send(JSON.stringify({ type: 'register', node_id: this._nodeId }));
console.log('Server WebSocket connection opened');
};

Expand Down

0 comments on commit 5fed471

Please sign in to comment.