-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FE] Todo API 웹소켓으로 변경
- Loading branch information
Showing
61 changed files
with
324 additions
and
212 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
2 changes: 1 addition & 1 deletion
2
frontend/src/apis/category.ts → frontend/src/apis/http/category.ts
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
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
frontend/src/apis/member.ts → frontend/src/apis/http/member.ts
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
2 changes: 1 addition & 1 deletion
2
frontend/src/apis/referenceLink.ts → frontend/src/apis/http/referenceLink.ts
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
2 changes: 1 addition & 1 deletion
2
frontend/src/apis/retrospect.ts → frontend/src/apis/http/retrospect.ts
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Client } from '@stomp/stompjs'; | ||
|
||
import { publishMessage } from '@/apis/websocket/websocket'; | ||
|
||
export const publishTodoMessage = { | ||
add: (client: Client | null, accessCode: string, contents: string) => { | ||
publishMessage(client, `/send/${accessCode}/todo/add`, { contents }); | ||
}, | ||
updateContents: (client: Client | null, accessCode: string, todoId: number, contents: string) => { | ||
publishMessage(client, `/send/${accessCode}/todo/update/${todoId}/contents`, { contents }); | ||
}, | ||
updateOrder: (client: Client | null, accessCode: string, todoId: number, order: number) => { | ||
publishMessage(client, `/send/${accessCode}/todo/update/${todoId}/order`, { order }); | ||
}, | ||
updateChecked: (client: Client | null, accessCode: string, todoId: number) => { | ||
publishMessage(client, `/send/${accessCode}/todo/update/${todoId}/checked`); | ||
}, | ||
delete: (client: Client | null, accessCode: string, todoId: number) => { | ||
publishMessage(client, `/send/${accessCode}/todo/delete/${todoId}`); | ||
}, | ||
}; |
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,31 @@ | ||
import { Client, Message } from '@stomp/stompjs'; | ||
|
||
const SOCKET_URL = process.env.REACT_SOCKET_API_URL; | ||
|
||
export const getConnection = () => { | ||
return new Client({ brokerURL: `${SOCKET_URL}/ws-connect` }); | ||
}; | ||
|
||
export const subscribeTopic = <T>(client: Client | null, destination: string, handler: (body: T) => void) => { | ||
if (!client?.connected) { | ||
console.error('웹소켓 연결에 실패했습니다.'); | ||
return; | ||
} | ||
|
||
client.subscribe(destination, (message: Message) => { | ||
const body: T = JSON.parse(message.body); | ||
handler(body); | ||
}); | ||
}; | ||
|
||
export const publishMessage = (client: Client | null, destination: string, contents?: object) => { | ||
if (!client?.connected) { | ||
console.error('[ERROR] 서버와 통신에 실패했습니다.'); | ||
return; | ||
} | ||
|
||
client.publish({ | ||
destination: destination, | ||
body: JSON.stringify(contents), | ||
}); | ||
}; |
2 changes: 1 addition & 1 deletion
2
frontend/src/components/CompletedPairRoom/ReferenceCard/ReferenceList/ReferenceList.tsx
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
2 changes: 1 addition & 1 deletion
2
frontend/src/components/CompletedPairRoom/TodoListCard/TodoItem/TodoItem.tsx
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
2 changes: 1 addition & 1 deletion
2
frontend/src/components/PairRoom/ReferenceCard/ReferenceList/ReferenceList.tsx
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
6 changes: 0 additions & 6 deletions
6
frontend/src/components/PairRoom/TodoListCard/TodoListCard.type.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.