-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: 라이브러리 설치 * feat: 안건 일시정지 아이콘 추가 * feat: 안건 제어 및 갱신 웹소켓 코드 작성 * feat: 전체 회의 소요시간 조회 웹소켓 코드 작성 * feat: 웹소켓 코드 export * style: css 수정 * fix: 회의 api 오류 수정
- Loading branch information
1 parent
dbade13
commit e3c858c
Showing
14 changed files
with
406 additions
and
12 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 was deleted.
Oops, something went wrong.
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 +1,2 @@ | ||
export const BASE_URL = 'http://facerain-dev.iptime.org:8080'; | ||
export const BROKER_URL = 'ws://facerain-dev.iptime.org:8080/ws'; |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,91 @@ | ||
import { useCallback, useEffect, useRef } from 'react'; | ||
import * as StompJs from '@stomp/stompjs'; | ||
// import SockJS from 'sockjs-client'; | ||
|
||
import { getCookie } from '@shared/common/utils'; | ||
import { useGetAgendaList } from '@shared/meeting/apis'; | ||
import { BROKER_URL } from '@shared/common/constants'; | ||
|
||
export const useControlAgenda = ( | ||
meetingId: string, | ||
agendaId: number, | ||
isFirstPendingAgenda: boolean | ||
) => { | ||
const client = useRef<StompJs.Client | null>(); | ||
|
||
const { refetch: refetchAgendaList } = useGetAgendaList({ | ||
token: getCookie('token'), | ||
meetingId | ||
}); | ||
|
||
const connect = useCallback(() => { | ||
client.current = new StompJs.Client({ | ||
brokerURL: BROKER_URL, | ||
connectHeaders: { | ||
Authorization: `${getCookie('token')}` | ||
}, | ||
// debug: (str) => { | ||
// console.log(str); | ||
// }, | ||
reconnectDelay: 5000, | ||
heartbeatIncoming: 4000, | ||
heartbeatOutgoing: 4000 | ||
}); | ||
|
||
// client.current.webSocketFactory = function () { | ||
// return new SockJS( | ||
// 'http://facerain-dev.iptime.org:8080/ws' | ||
// ); | ||
// }; | ||
|
||
const callback = (message: StompJs.Message) => { | ||
if (message.body) { | ||
// console.log(JSON.parse(message.body)); | ||
refetchAgendaList(); | ||
} | ||
}; | ||
|
||
const subscribe = () => { | ||
// console.log('[구독]', client.current); | ||
client.current?.subscribe( | ||
`/topic/meeting/${meetingId}/agendas/${agendaId}/status`, | ||
callback | ||
); | ||
}; | ||
|
||
client.current.onConnect = () => { | ||
subscribe(); | ||
}; | ||
|
||
client.current.activate(); | ||
|
||
// changeClient(client.current); // 클라이언트 갱신 | ||
}, [meetingId, agendaId, refetchAgendaList]); | ||
|
||
const sendMessage = (action: string) => { | ||
// console.log('[메세지 전송]', client.current); | ||
client.current?.publish({ | ||
destination: `/app/meeting/${meetingId}/agendas/${agendaId}/action`, | ||
body: JSON.stringify({ | ||
action | ||
}) | ||
}); | ||
}; | ||
|
||
const disConnect = () => { | ||
if (client.current === null) { | ||
return; | ||
} | ||
client.current?.deactivate(); | ||
}; | ||
|
||
useEffect(() => { | ||
if (isFirstPendingAgenda) { | ||
// console.log(isFirstPendingAgenda, agendaId); | ||
connect(); | ||
} | ||
// return () => disConnect(); | ||
}, [isFirstPendingAgenda, connect]); | ||
|
||
return { connect, disConnect, sendMessage }; | ||
}; |
69 changes: 69 additions & 0 deletions
69
src/shared/meeting/apis/webSockets/useGetMeetingDuration.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { useEffect, useRef } from 'react'; | ||
import * as StompJs from '@stomp/stompjs'; | ||
// import SockJS from 'sockjs-client'; | ||
|
||
import { getCookie } from '@shared/common/utils'; | ||
|
||
export const useGetMeetingDuration = () => { | ||
const client = useRef<StompJs.Client | null>(); | ||
|
||
const connect = () => { | ||
client.current = new StompJs.Client({ | ||
brokerURL: 'ws://facerain-dev.iptime.org:8080/ws', | ||
connectHeaders: { | ||
Authorization: `${getCookie('token')}` | ||
}, | ||
debug: (str) => { | ||
console.log(str); | ||
}, | ||
reconnectDelay: 5000, | ||
heartbeatIncoming: 4000, | ||
heartbeatOutgoing: 4000 | ||
}); | ||
|
||
// client.current.webSocketFactory = function () { | ||
// return new SockJS( | ||
// 'http://facerain-dev.iptime.org:8080/ws/app/meeting/65/agendas/59/action?action=resume' | ||
// ); | ||
// }; | ||
|
||
const callback = (message: StompJs.Message) => { | ||
if (message.body) { | ||
console.log('[회의실 입장]', JSON.parse(message.body)); | ||
// let msg = JSON.parse(message.body); | ||
} | ||
}; | ||
|
||
const subscribe = () => { | ||
client.current?.subscribe('/topic/meeting/65/current-duration', callback); | ||
}; | ||
|
||
const sendMessage = () => { | ||
client.current?.publish({ | ||
destination: '/app/meeting/65/current-duration', | ||
body: JSON.stringify({}) | ||
}); | ||
}; | ||
|
||
client.current.onConnect = () => { | ||
subscribe(); | ||
sendMessage(); | ||
}; | ||
|
||
client.current.activate(); | ||
|
||
// changeClient(client.current); // 클라이언트 갱신 | ||
}; | ||
|
||
const disConnect = () => { | ||
if (client.current === null) { | ||
return; | ||
} | ||
client.current?.deactivate(); | ||
}; | ||
|
||
useEffect(() => { | ||
connect(); | ||
return () => disConnect(); | ||
}, []); | ||
}; |
Oops, something went wrong.