nano javascript WebSocket client SDK
nano . init ( params , callback ) ; Examples
nano . init ( { host :host , port :port , user :{ } , handshakeCallback :function ( ) { } } , function ( ) { console . log ( 'success' ) ; } ) ; Send request to server with callback nano . request ( route , msg , callback ) ; Examples
nano . request ( route , { rid :rid } , function ( data ) { console . log ( dta ) ; } ) ; Send request to server without callback nano . notify ( route , params ) ; Receive message from server Examples
nano . on ( 'onChat' , function ( data ) { addMessage ( data . from , data . target , data . msg ) ; $ ( "#chatHistory" ) . show ( ) ; } ) ; <!DOCTYPE html/> < html > < head > < title > nano WebSocket Test Page</ title > </ head > < body > < script src ="./protocol.js "> </ script > < script src ="./nano-websocket-client.js "> </ script > < script type ="text/javascript "> var nano = window . nano nano . init ( { host :"127.0.0.1" , port :3250 , log :true } , function ( ) { nano . request ( "gate.Handler.Login" , { "name" :"chrislonng" , "age" :10000 } , function ( data ) { console . log ( data ) ; } ) ; nano . request ( "gate.Handler.Signup" , { "name" :"Signup chrislonng" , "age" :10000 } , function ( data ) { console . log ( data ) ; } ) ; nano . on ( "notify" , function ( data ) { console . log ( data ) ; } ) ; } ) ; </ script > </ body > </ html > MIT License