@@ -7,8 +7,7 @@ class WebSocketService {
77 this . stompClient = null
88 this . isConnected = ref ( false )
99 this . isConnecting = ref ( false )
10- this . messageHandlers = new Map ( ) // topic -> subscription
11- this . handlersByTopic = new Map ( ) // topic -> handler ✅ 추가
10+ this . messageHandlers = new Map ( )
1211 this . connectionHandlers = [ ]
1312 this . pendingSubscriptions = [ ] // 대기 중인 구독들
1413 }
@@ -42,7 +41,7 @@ class WebSocketService {
4241 this . stompClient = new Client ( {
4342 webSocketFactory : ( ) => socket ,
4443 reconnectDelay : 2000 , // 재연결 지연 시간 단축
45- debug : ( str ) => console . log ( '[STOMP DEBUG]' , str ) ,
44+ // debug: (str) => console.log('[STOMP DEBUG]', str),
4645 onConnect : ( frame ) => {
4746 console . log ( 'STOMP 연결 성공:' , frame )
4847 this . isConnected . value = true
@@ -84,27 +83,16 @@ class WebSocketService {
8483 }
8584
8685 async sendMessage ( destination , message , retryCount = 5 ) {
87- console . log ( 'sendMessage 호출:' , { destination, message } )
88-
8986 // STOMP 클라이언트가 없으면 연결 시도
9087 if ( ! this . stompClient ) {
91- console . log ( 'STOMP 클라이언트가 없음, 연결 시도...' )
9288 await this . connect ( )
9389 }
9490
9591 // 연결 상태 확인
9692 const isReady = this . stompClient ?. connected && this . isConnected . value
9793
98- console . log ( 'STOMP 상태:' , {
99- hasClient : ! ! this . stompClient ,
100- connected : this . stompClient ?. connected ,
101- internalConnected : this . isConnected . value ,
102- isReady : isReady ,
103- } )
104-
10594 if ( ! isReady ) {
10695 if ( retryCount > 0 ) {
107- console . warn ( `STOMP 연결 대기 중... (남은 시도: ${ retryCount } )` )
10896 await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) )
10997 return this . sendMessage ( destination , message , retryCount - 1 )
11098 } else {
@@ -114,21 +102,14 @@ class WebSocketService {
114102 }
115103
116104 try {
117- const payload = {
118- ...message ,
119- }
120-
121- console . log ( '전송할 페이로드:' , payload )
122105 this . stompClient . publish ( {
123106 destination,
124- body : JSON . stringify ( payload ) ,
107+ body : JSON . stringify ( message ) ,
125108 } )
126- console . log ( '메시지 전송 성공' )
127109 return true
128110 } catch ( error ) {
129111 console . error ( '메시지 전송 실패:' , error )
130112 if ( retryCount > 0 ) {
131- console . log ( `메시지 전송 재시도... (남은 시도: ${ retryCount } )` )
132113 await new Promise ( ( resolve ) => setTimeout ( resolve , 200 ) )
133114 return this . sendMessage ( destination , message , retryCount - 1 )
134115 }
@@ -201,16 +182,16 @@ class WebSocketService {
201182 }
202183
203184 // 계약서 내보내기 관련 메서드
204- sendContractExportSignature ( contractChatId , signatureData ) {
205- return this . sendMessage ( `/app/contract/${ contractChatId } /export/signature` , signatureData )
185+ async sendContractExportSignature ( contractChatId , signatureData ) {
186+ return await this . sendMessage ( `/app/contract/${ contractChatId } /export/signature` , signatureData )
206187 }
207188
208- sendContractExportPassword ( contractChatId , passwordData ) {
209- return this . sendMessage ( `/app/contract/${ contractChatId } /export/password` , passwordData )
189+ async sendContractExportPassword ( contractChatId , passwordData ) {
190+ return await this . sendMessage ( `/app/contract/${ contractChatId } /export/password` , passwordData )
210191 }
211192
212- getContractExportStatus ( contractChatId ) {
213- return this . sendMessage ( `/app/contract/${ contractChatId } /export/status` , { } )
193+ async getContractExportStatus ( contractChatId ) {
194+ return await this . sendMessage ( `/app/contract/${ contractChatId } /export/status` , { } )
214195 }
215196
216197 onMessage ( topic , handler ) {
@@ -250,8 +231,7 @@ class WebSocketService {
250231 const subscription = this . stompClient . subscribe ( topic , ( message ) => {
251232 try {
252233 const data = JSON . parse ( message . body )
253- const result = handler ( data )
254- console . log ( '핸들러 호출 완료! 결과:' , result )
234+ handler ( data )
255235 } catch ( e ) {
256236 console . error ( '파싱 실패:' , e )
257237 console . error ( 'Raw body:' , message . body )
@@ -297,4 +277,4 @@ class WebSocketService {
297277}
298278
299279export const websocketService = new WebSocketService ( )
300- export default websocketService
280+ export default websocketService
0 commit comments