-
Notifications
You must be signed in to change notification settings - Fork 5
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 #112 from nicolelim02/feat/communication
Refactor code
- Loading branch information
Showing
8 changed files
with
40 additions
and
22 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
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
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,11 +1,12 @@ | ||
import { io } from "socket.io-client"; | ||
import { getToken } from "./token"; | ||
|
||
const MATCH_SOCKET_URL = "http://localhost:3002"; | ||
|
||
export const matchSocket = io(MATCH_SOCKET_URL, { | ||
reconnectionAttempts: 3, | ||
autoConnect: false, | ||
auth: { | ||
token: `Bearer ${localStorage.getItem("token")}`, | ||
token: getToken(), | ||
}, | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const setToken = (token: string) => { | ||
localStorage.setItem("accessToken", token); | ||
}; | ||
|
||
export const getToken = () => { | ||
const token = localStorage.getItem("accessToken"); | ||
const bearerToken = `Bearer ${token}`; | ||
return bearerToken; | ||
}; | ||
|
||
export const removeToken = () => { | ||
localStorage.removeItem("accessToken"); | ||
}; |