@@ -162,10 +162,12 @@ export class YjsProvider {
162162 if ( ! this . socket ) return ;
163163
164164 this . socket . on ( "connect" , ( ) => {
165+ console . log ( "[EVENT] connect" ) ;
165166 this . isConnected = true ;
166167 } ) ;
167168
168- this . socket . on ( "disconnect" , ( ) => {
169+ this . socket . on ( "disconnect" , ( reason : string ) => {
170+ console . log ( "[EVENT] disconnect / reason:" , reason ) ;
169171 this . isConnected = false ;
170172 this . hasAccess = false ;
171173 } ) ;
@@ -174,7 +176,8 @@ export class YjsProvider {
174176 this . socket . on (
175177 "cardset-state" ,
176178 ( data : { cardsetId : string ; cards : any [ ] } ) => {
177- console . log ( "[YJS] Received cardset state" , data ) ;
179+ console . log ( "[EVENT] cardset-state" ) ;
180+ console . log ( "[CARDSET-STATE] data:" , data ) ;
178181 // 서버에서 보낸 초기 상태는 무시 (Yjs sync로 받을 것)
179182 }
180183 ) ;
@@ -220,19 +223,37 @@ export class YjsProvider {
220223 this . socket . on ( "awareness" , ( message : AwarenessMessage ) => {
221224 if ( ! this . hasAccess ) return ;
222225
226+ console . log ( "[EVENT] awareness" ) ;
227+ console . log ( "[AWARENESS] raw type:" , typeof message , "/ value:" , message ) ;
228+
223229 const { awareness } = message ;
230+ console . log ( "[AWARENESS] awareness field:" , awareness ) ;
224231 awarenessProtocol . applyAwarenessUpdate ( this . awareness , awareness , this ) ;
225232 } ) ;
226233
227234 // 토큰 만료 처리
228235 this . socket . on ( "expired" , ( ) => {
236+ console . log ( "[EVENT] expired" ) ;
229237 this . hasAccess = false ;
230238 this . disconnect ( ) ;
231239 } ) ;
240+
241+ // 에러 처리
242+ this . socket . on ( "error" , ( message : any ) => {
243+ console . log ( "[EVENT] error" ) ;
244+ console . log ( "[ERROR] raw type:" , typeof message , "/ value:" , message ) ;
245+ try {
246+ const decoded = new TextDecoder ( ) . decode ( message ) ;
247+ console . log ( "[ERROR] decoded:" , JSON . parse ( decoded ) ) ;
248+ } catch {
249+ console . log ( "[ERROR] could not decode as JSON" ) ;
250+ }
251+ } ) ;
232252 }
233253
234254 private sendMessage ( { type, data } : YjsMessage ) : void {
235255 if ( this . socket ?. connected ) {
256+ console . log ( "[EMIT]" , type , "/ data:" , data ) ;
236257 this . socket . emit ( type , data ) ;
237258 }
238259 }
0 commit comments