@@ -31,36 +31,40 @@ export class OpenSeaStreamClient {
3131 onError = ( error ) => this . error ( error )
3232 } : ClientConfig ) {
3333 const endpoint = apiUrl || ENDPOINTS [ network ] ;
34+ const webTransportDefault =
35+ typeof window !== 'undefined' ? window . WebSocket : undefined ;
3436 this . socket = new Socket ( endpoint , {
3537 params : { token } ,
38+ transport : webTransportDefault ,
3639 ...connectOptions
3740 } ) ;
41+
3842 this . socket . onError ( onError ) ;
3943 this . channels = new Map < string , Channel > ( ) ;
4044 this . logLevel = logLevel ;
4145 }
4246
4347 private debug ( message : unknown ) {
4448 if ( this . logLevel <= LogLevel . DEBUG ) {
45- console . debug ( message ) ;
49+ console . debug ( `[DEBUG]: ${ message } ` ) ;
4650 }
4751 }
4852
4953 private info ( message : unknown ) {
5054 if ( this . logLevel <= LogLevel . INFO ) {
51- console . info ( message ) ;
55+ console . info ( `[INFO]: ${ message } ` ) ;
5256 }
5357 }
5458
5559 private warn ( message : unknown ) {
5660 if ( this . logLevel <= LogLevel . WARN ) {
57- console . warn ( message ) ;
61+ console . warn ( `[WARN]: ${ message } ` ) ;
5862 }
5963 }
6064
6165 private error ( message : unknown ) {
6266 if ( this . logLevel <= LogLevel . ERROR ) {
63- console . error ( message ) ;
67+ console . error ( `[ERROR]: ${ message } ` ) ;
6468 }
6569 }
6670
@@ -90,6 +94,7 @@ export class OpenSeaStreamClient {
9094 private getChannel = ( topic : string ) : Channel => {
9195 let channel = this . channels . get ( topic ) ;
9296 if ( ! channel ) {
97+ this . debug ( `Creating channel for topic: "${ topic } "` ) ;
9398 channel = this . createChannel ( topic ) ;
9499 }
95100 return channel ;
@@ -103,9 +108,12 @@ export class OpenSeaStreamClient {
103108 this . socket . connect ( ) ;
104109
105110 const topic = collectionTopic ( collectionSlug ) ;
111+ this . debug ( `Fetching channel ${ topic } ` ) ;
106112 const channel = this . getChannel ( topic ) ;
113+ this . debug ( `Subscribing to ${ eventType } events on ${ topic } ` ) ;
107114 channel . on ( eventType , callback ) ;
108115 return ( ) => {
116+ this . debug ( `Unsubscribing from ${ eventType } events on ${ topic } ` ) ;
109117 channel . leave ( ) . receive ( 'ok' , ( ) => {
110118 this . channels . delete ( topic ) ;
111119 this . info (
0 commit comments