Skip to content

Commit

Permalink
fix node test
Browse files Browse the repository at this point in the history
  • Loading branch information
jczhong84 committed Aug 14, 2023
1 parent f0cf15b commit 997c8ee
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions querybook/webapp/lib/ai-assistant/ai-assistant-socketio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,26 @@ class AIAssistantSocket {
private socket: Socket = null;
private socketPromise: Promise<Socket> = null;

constructor() {
public constructor() {
this.setupSocket();
}

public onSocketConnect(socket: Socket) {
socket.emit('subscribe');
}

public requestAIAssistant = (command: AICommandType, payload: object) => {
this.socket.emit(AI_ASSISTANT_REQUEST_EVENT, command, payload);
};

public addAIListener = (listener) => {
this.socket.on(AI_ASSISTANT_RESPONSE_EVENT, listener);
};

public removeAIListener = (listener) => {
this.socket.off(AI_ASSISTANT_RESPONSE_EVENT, listener);
};

private setupSocket = async () => {
if (this.socket) {
return this.socket;
Expand All @@ -44,18 +56,6 @@ class AIAssistantSocket {

return this.socket;
};

public requestAIAssistant = (command: AICommandType, payload: object) => {
this.socket.emit(AI_ASSISTANT_REQUEST_EVENT, command, payload);
};

public addAIListener = (listener) => {
this.socket.on(AI_ASSISTANT_RESPONSE_EVENT, listener);
};

public removeAIListener = (listener) => {
this.socket.off(AI_ASSISTANT_RESPONSE_EVENT, listener);
};
}

const defaultSocket = new AIAssistantSocket();
Expand Down

0 comments on commit 997c8ee

Please sign in to comment.