Skip to content

Commit

Permalink
Update wss url
Browse files Browse the repository at this point in the history
  • Loading branch information
atul24112001 committed Nov 6, 2024
1 parent fbd0c91 commit bef311c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func main() {
http.HandleFunc("/ws", handleWebSocket)
http.Handle("/api/user", httpCorsMiddleware(http.HandlerFunc(user.Handler)))
http.Handle("/api/auth", httpCorsMiddleware(http.HandlerFunc(auth.Handler)))
http.Handle("/api/transaction", httpCorsMiddleware(http.HandlerFunc(transaction.Handler)))
http.Handle("/api/transaction", http.HandlerFunc(transaction.Handler))
http.Handle("/api/game-types", httpCorsMiddleware(http.HandlerFunc(gametype.Handler)))

fmt.Println("WebSocket server listening on :8080")
Expand Down
8 changes: 5 additions & 3 deletions web/src/context/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,22 @@ export const AuthContextProvider = ({ children }: PropsWithChildren) => {

useEffect(() => {
if (user && !socket) {
const ws = new WebSocket(`${process.env.NEXT_PUBLIC_API_URL}/ws`);
const ws = new WebSocket(`${process.env.NEXT_PUBLIC_WSS}/ws`);

ws.onopen = () => {
setSocket(ws);
};

ws.onclose = () => {
ws.onclose = (e) => {
console.log(e);
wallet.disconnect();
setUser(null);
setToken(null);
localStorage.removeItem("token");
};

ws.onerror = () => {
ws.onerror = (e) => {
console.log(e);
wallet.disconnect();
setUser(null);
setToken(null);
Expand Down

0 comments on commit bef311c

Please sign in to comment.