Skip to content

Commit ef81a48

Browse files
committed
🐛 fix: 다 수정 해버릴거야
1 parent d712614 commit ef81a48

File tree

5 files changed

+344
-83
lines changed

5 files changed

+344
-83
lines changed

src/apis/contractChatApi.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,14 @@ export const updateSignatureStatus = async (contractChatId, signatureData) => {
461461
export const getExportStatus = async (contractChatId) => {
462462
try {
463463
const response = await api.get(`/api/contract/${contractChatId}/export/status`)
464-
return response.data.data
464+
if (response.data && response.data.success) {
465+
return response.data.data
466+
} else {
467+
return null
468+
}
465469
} catch (error) {
466470
console.error('내보내기 상태 조회 실패:', error)
467-
throw error
471+
return null
468472
}
469473
}
470474

src/apis/websocket.js

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -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

299279
export const websocketService = new WebSocketService()
300-
export default websocketService
280+
export default websocketService

src/components/contract/chat/ContractChat.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,11 @@ watch(
659659
return
660660
}
661661
662+
// WebSocket 메시지 이벤트 발생
663+
window.dispatchEvent(new CustomEvent('contract-chat-message', {
664+
detail: { content: t, senderId: sid }
665+
}))
666+
662667
// 1) 임차인이 거절한 경우: "임차인이 특약 대화를 더 요청했습니다."
663668
if (amOwner.value && t.includes('임차인이 특약 대화를 더 요청했습니다.')) {
664669
isLoadingOverlayVisible.value = false

0 commit comments

Comments
 (0)