diff --git a/packages/common/src/components/chat/index.ts b/packages/common/src/components/chat/index.ts index 2732bb46..8ff0e7a2 100644 --- a/packages/common/src/components/chat/index.ts +++ b/packages/common/src/components/chat/index.ts @@ -30,4 +30,3 @@ export { default as BlockedChat } from './BlockedChat.tsx'; export { default as ChatList } from './ChatList.tsx'; export { default as Message } from './Message.tsx'; export { default as Notice } from './Notice.tsx'; - diff --git a/packages/common/src/utils/socket.ts b/packages/common/src/utils/socket.ts index e61e27fd..b9f9ed9b 100644 --- a/packages/common/src/utils/socket.ts +++ b/packages/common/src/utils/socket.ts @@ -15,18 +15,15 @@ export interface SendMessageProps { headers?: Record; } -export interface ConnectProps { - isSuccess: boolean; - options?: IFrame; -} - export default class Socket { - private client: Client; + client: Client; private subscriptions: Map = new Map(); private token?: string | undefined | null = undefined; + isConnected: boolean = false; + constructor(url: string, token?: string | null) { let baseUrl = url; if (token) { @@ -39,34 +36,39 @@ export default class Socket { private setup(url: string): Client { const stompClient = new Client({ webSocketFactory: () => new SockJS(url), - reconnectDelay: 5000, // Reconnect if the connection drops + reconnectDelay: 5000, }); this.client = stompClient; return stompClient; } - connect(callback?: (props: ConnectProps) => void) { - this.client.onConnect = (options) => { - callback?.({ isSuccess: true, options }); - }; + async connect(): Promise