-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #705 from openchatai/fixxxx
Fix the json parsing issues
- Loading branch information
Showing
6 changed files
with
44 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,22 @@ | ||
import { Socket, io } from "socket.io-client"; | ||
import { io } from "socket.io-client"; | ||
|
||
interface ConfigType { | ||
socketUrl: string; | ||
token: string; | ||
sessionId: string; | ||
} | ||
|
||
const sockets = new Map<string, Socket>(); | ||
|
||
export function createSocketClient({ | ||
socketUrl, | ||
token, | ||
sessionId, | ||
}: ConfigType) { | ||
const socket = sockets.get(sessionId + token); | ||
if (socket) { | ||
return socket; | ||
} | ||
const newSocket = io(socketUrl, { | ||
return io(socketUrl, { | ||
autoConnect: false, | ||
transports: ["websocket"], | ||
extraHeaders: { | ||
"X-Bot-Token": token, | ||
"X-Session-Id": sessionId, | ||
}, | ||
}); | ||
sockets.set(sessionId + token, newSocket); | ||
return newSocket; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.