File tree Expand file tree Collapse file tree 6 files changed +14
-5
lines changed Expand file tree Collapse file tree 6 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,8 @@ function Editor() {
7979
8080 // crdtμ μ΄κΈ°νμ μμΌμ ν΅ν΄ μ λ¬λ°λ 리λͺ¨νΈ μ°μ° μ²λ¦¬
8181 useEffect ( ( ) => {
82+ socket . emit ( 'mom-initialization' ) ;
83+
8284 socket . on ( 'mom-initialization' , ( crdt ) => {
8385 syncCRDT ( crdt ) ;
8486
Original file line number Diff line number Diff line change @@ -2,4 +2,5 @@ export default {
22 GITHUB_CLIENT_ID : import . meta. env . VITE_GITHUB_CLIENT_ID ,
33 GITHUB_CLIENT_SECRET : import . meta. env . VITE_GITHUB_CLIENT_SECRET ,
44 SERVER_PATH : import . meta. env . VITE_SERVER_PATH ,
5+ SERVER_URL : import . meta. env . VITE_SERVER_URL ,
56} ;
Original file line number Diff line number Diff line change @@ -2,5 +2,8 @@ import { io } from 'socket.io-client';
22import env from 'src/config' ;
33
44export default function useSocket ( namespace : string ) {
5- return io ( `${ env . SERVER_PATH } ${ namespace } ` ) ;
5+ // TODO: http://example.com/ κΉμ§λ§ λνλ΄λ νκ²½λ³μλ‘ SERVER_URL μ¬μ©.
6+ // SERVER_PATH νκ²½λ³μ(http://example.com/api)μ κ²ΉμΉλ λΆλΆμ΄ μμΌλ―λ‘ λ¦¬ν©ν λ§ νμ
7+ // TODO: '/ws' λΆλΆμ νκ²½λ³μλ‘ κ΄λ¦¬νκΈ°. μ 리ν©ν λ§ μ§νμ κ°μ΄ μ§ν νμ
8+ return io ( `${ env . SERVER_URL } ${ namespace } ` , { path : '/ws' } ) ;
69}
Original file line number Diff line number Diff line change @@ -29,11 +29,12 @@ const io = new Server({
2929 cors : {
3030 origin : env . CLIENT_PATH ,
3131 } ,
32+ path : '/ws' , // TODO: '/ws' νκ²½ λ³μλ‘ λΆλ¦¬ νμ
3233} ) ;
3334
3435momSocketServer ( io ) ;
3536signalingSocketServer ( io ) ;
3637
3738io . attach ( server ) ;
3839
39- server . listen ( 8080 ) ;
40+ server . listen ( 8080 ) ; // TODO: μλ² ν¬νΈ νκ²½ λ³μλ‘ λΆλ¦¬ νμ
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ async function momSocketServer(io: Server) {
99
1010 const crdt = new CRDT ( 1 , - 1 , structure ) ;
1111
12- const workspace = io . of ( / ^ \/ a p i \/ s c - w o r k s p a c e \/ \d + $ / ) ;
12+ const workspace = io . of ( / ^ \/ s c - w o r k s p a c e \/ \d + $ / ) ;
1313
1414 workspace . on ( 'connection' , async ( socket ) => {
1515 const name = socket . nsp . name ;
@@ -70,7 +70,9 @@ async function momSocketServer(io: Server) {
7070 // μ΄κΈ°νμ νμν μ 보 μ λ¬
7171 const { structure } = await getMom ( momId ) ;
7272
73- socket . emit ( 'mom-initialization' , structure ) ;
73+ socket . on ( 'mom-initialization' , ( ) => {
74+ socket . emit ( 'mom-initialization' , structure ) ;
75+ } ) ;
7476 } ) ;
7577}
7678
Original file line number Diff line number Diff line change 11import { Server } from 'socket.io' ;
22
33function signalingSocketServer ( io : Server ) {
4- const signaling = io . of ( / ^ \/ a p i \/ s i g n a l i n g \/ \d + $ / ) ;
4+ const signaling = io . of ( / ^ \/ s i g n a l i n g \/ \d + $ / ) ;
55
66 signaling . on ( 'connection' , ( socket ) => {
77 socket . on ( 'send_hello' , ( ) => {
You canβt perform that action at this time.
0 commit comments