| .. | .. |
|---|
| 23 | 23 | status: ConnectionStatus; |
|---|
| 24 | 24 | connect: (config?: ServerConfig) => void; |
|---|
| 25 | 25 | disconnect: () => void; |
|---|
| 26 | | - sendTextMessage: (text: string) => boolean; |
|---|
| 27 | | - sendVoiceMessage: (audioBase64: string, transcript?: string, messageId?: string) => boolean; |
|---|
| 28 | | - sendImageMessage: (imageBase64: string, caption: string, mimeType: string) => boolean; |
|---|
| 29 | | - sendCommand: (command: string, args?: Record<string, unknown>) => boolean; |
|---|
| 26 | + sendTextMessage: (text: string, sessionId?: string) => boolean; |
|---|
| 27 | + sendVoiceMessage: (audioBase64: string, transcript?: string, messageId?: string, sessionId?: string) => boolean; |
|---|
| 28 | + sendImageMessage: (imageBase64: string, caption: string, mimeType: string, sessionId?: string) => boolean; |
|---|
| 29 | + sendCommand: (command: string, args?: Record<string, unknown>, sessionId?: string) => boolean; |
|---|
| 30 | 30 | saveServerConfig: (config: ServerConfig) => Promise<void>; |
|---|
| 31 | 31 | onMessageReceived: React.MutableRefObject< |
|---|
| 32 | 32 | ((data: WsIncoming) => void) | null |
|---|
| .. | .. |
|---|
| 116 | 116 | setServerConfig(config); |
|---|
| 117 | 117 | }, []); |
|---|
| 118 | 118 | |
|---|
| 119 | | - const sendTextMessage = useCallback((text: string): boolean => { |
|---|
| 120 | | - return wsClient.send({ type: "text", content: text }); |
|---|
| 119 | + const sendTextMessage = useCallback((text: string, sessionId?: string): boolean => { |
|---|
| 120 | + return wsClient.send({ type: "text", content: text, sessionId }); |
|---|
| 121 | 121 | }, []); |
|---|
| 122 | 122 | |
|---|
| 123 | 123 | const sendVoiceMessage = useCallback( |
|---|
| 124 | | - (audioBase64: string, transcript: string = "", messageId?: string): boolean => { |
|---|
| 124 | + (audioBase64: string, transcript: string = "", messageId?: string, sessionId?: string): boolean => { |
|---|
| 125 | 125 | return wsClient.send({ |
|---|
| 126 | 126 | type: "voice", |
|---|
| 127 | 127 | content: transcript, |
|---|
| 128 | 128 | audioBase64, |
|---|
| 129 | 129 | messageId, |
|---|
| 130 | + sessionId, |
|---|
| 130 | 131 | }); |
|---|
| 131 | 132 | }, |
|---|
| 132 | 133 | [] |
|---|
| 133 | 134 | ); |
|---|
| 134 | 135 | |
|---|
| 135 | 136 | const sendImageMessage = useCallback( |
|---|
| 136 | | - (imageBase64: string, caption: string = "", mimeType: string = "image/jpeg"): boolean => { |
|---|
| 137 | | - return wsClient.send({ type: "image", imageBase64, caption, mimeType }); |
|---|
| 137 | + (imageBase64: string, caption: string = "", mimeType: string = "image/jpeg", sessionId?: string): boolean => { |
|---|
| 138 | + return wsClient.send({ type: "image", imageBase64, caption, mimeType, sessionId }); |
|---|
| 138 | 139 | }, |
|---|
| 139 | 140 | [] |
|---|
| 140 | 141 | ); |
|---|
| 141 | 142 | |
|---|
| 142 | 143 | const sendCommand = useCallback( |
|---|
| 143 | | - (command: string, args?: Record<string, unknown>): boolean => { |
|---|
| 144 | | - const msg: WsOutgoing = { type: "command", command, args }; |
|---|
| 144 | + (command: string, args?: Record<string, unknown>, sessionId?: string): boolean => { |
|---|
| 145 | + const msg: WsOutgoing = { type: "command", command, args, sessionId }; |
|---|
| 145 | 146 | return wsClient.send(msg as any); |
|---|
| 146 | 147 | }, |
|---|
| 147 | 148 | [] |
|---|