Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

nano javascript WebSocket client SDK

License

NotificationsYou must be signed in to change notification settings

bytemode/nano-websocket-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

nano javascript WebSocket client SDK

API

Connect to server

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

nano.on(route,callback);

Examples

nano.on('onChat',function(data){addMessage(data.from,data.target,data.msg);$("#chatHistory").show();});

Disconnect from server

nano.disconnect();

Usage

<!DOCTYPE html/><html><head><title>nano WebSocket Test Page</title></head><body><scriptsrc="./protocol.js"></script><scriptsrc="./nano-websocket-client.js"></script><scripttype="text/javascript">varnano=window.nanonano.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>

License

MIT License

About

nano javascript WebSocket client SDK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript100.0%

[8]ページ先頭

©2009-2025 Movatter.jp