export interface SocketOptions { query ? : string | Object ; forceWebsockets ? : boolean ; android ? : any ; ios ? : any ; } export abstract class Common { protected _listeners = new WeakMap ( ) ; abstract get connected ( ) : boolean ; get disconnected ( ) { return ! this . connected ; } abstract connect ( ) ; abstract disconnect ( ) ; open ( ) { this . connect ( ) ; } close ( ) { this . disconnect ( ) ; } abstract on ( event , callback ) ; abstract once ( event , callback ) ; abstract off ( event , callback ? ) ; abstract emit ( event , ... payload ) ; addEventListener ( event , callback ) { return this . on ( event , callback ) ; } removeListener ( event , callback ? ) { return this . off ( event , callback ) ; } removeEventListener ( event , callback ? ) { return this . off ( event , callback ) ; } } export const debugNop = function ( ... args ) : void { } ; export function debugDefault ( ... args ) { args = args . map ( ( value ) => { if ( typeof value === 'object' && value ) { try { value = JSON . stringify ( value ) ; } catch ( e ) { value = value . toString ( ) ; } } return value ; } ) ; args . unshift ( 'nativescript-socket.io' ) ; console . log . apply ( console , args ) ; } let _debug = debugNop ; export function debug ( ... args ) { _debug . apply ( null , args ) ; } export function enableDebug ( debugFn = debugDefault ) { _debug = debugFn ; } export function disableDebug ( ) { _debug = debugNop ; }