socket.io client api
2015-12-16 14:51
295 查看
Client API
#IO(url:String,
opts:Object):Socket
Exposed as the ioglobal
in
windowif
using the standalone build (eg:
/socket.io/socket.io.jsor
the CDN), or the result of calling
require('socket.io-client').
When called, it creates a new
Managerfor
the given URL, and attempts
to reuse an existing
Managerfor
subsequent calls, unless the
multiplexoption
is passed with
false.
Passing this option is the equivalent of passing
'force new connection': true.
The rest of the options are passed to the
Managerconstructor
(see below
for details).
A
Socketinstance
is returned for the namespace specified by the
pathname in the URL, defaulting to
/.
For example, if the
urlis
http://localhost/users,
a transport connection will be established to
http://localhostand
a Socket.IO connection will be established to
/users.
#IO#protocol
Socket.io protocol revision number this client works with.
#IO#Socket
Reference to the Socketconstructor.
#IO#Manager
Reference to the Managerconstructor.
#IO#Emitter
Reference to the Emitterconstructor.
#Manager(url:String,
opts:Object)
A Managerrepresents
a connection to a given Socket.IO server. One or
more
Socketinstances
are associated with the manager. The manager
can be accessed through the
ioproperty
of each
Socketinstance.
The
optsare
also passed to
engine.ioupon
initialization of the
underlying
Socket.
Options:
–
reconnectionwhether
to reconnect automatically (
true)
–
reconnectionDelayhow
long to wait before attempting a new
reconnection (
1000)
–
reconnectionDelayMaxmaximum
amount of time to wait between
reconnections (
5000).
Each attempt increases the reconnection by
the amount specified by
reconnectionDelay.
–
timeoutconnection
timeout before a
connect_error
and
connect_timeoutevents
are emitted (
20000)
Events
connect.
Fired upon a successful connection.
connect_error.
Fired upon a connection error.
Parameters:
Objecterror
object
connect_timeout.
Fired upon a connection timeout.
reconnect.
Fired upon a successful reconnection.
Parameters:
Numberreconnection
attempt number
reconnect_attempt.
Fired upon an attempt to reconnect.
reconnecting.
Fired upon an attempt to reconnect.
Parameters:
Numberreconnection
attempt number
reconnect_error.
Fired upon a reconnection attempt error.
Parameters:
Objecterror
object
reconnect_failed.
Fired when couldn’t reconnect within
reconnectionAttempts
The events above are also emitted on the individual sockets that
reconnect that depend on this
Manager.
#Manager#reconnection(v:Boolean):Manager
Sets the reconnectionoption,
or returns it if no parameters
are passed.
#Manager#reconnectionAttempts(v:Boolean):Manager
Sets the reconnectionAttemptsoption,
or returns it if no parameters
are passed.
#Manager#reconnectionDelay(v:Boolean):Manager
Sets the reconectionDelayoption,
or returns it if no parameters
are passed.
#Manager#reconnectionDelayMax(v:Boolean):Manager
Sets the reconectionDelayMaxoption,
or returns it if no parameters
are passed.
#Manager#timeout(v:Boolean):Manager
Sets the timeoutoption,
or returns it if no parameters
are passed.
#Socket
Events
connect.
Fired upon connecting.
error.
Fired upon a connection error
Parameters:
Objecterror
data
disconnect.
Fired upon a disconnection.
reconnect.
Fired upon a successful reconnection.
Parameters:
Numberreconnection
attempt number
reconnect_attempt.
Fired upon an attempt to reconnect.
reconnecting.
Fired upon an attempt to reconnect.
Parameters:
Numberreconnection
attempt number
reconnect_error.
Fired upon a reconnection attempt error.
Parameters:
Objecterror
object
reconnect_failed.
Fired when couldn’t reconnect within
reconnectionAttempts
相关文章推荐
- Android Manifest 用法
- 什么是 GraphQL?
- Spark RDD API详解(一) Map和Reduce
- 一个小型js框架myJSFrame附API使用帮助
- 详细分析交换机、路由器、集线器的区别和联系
- PowerShell打开或关闭光驱
- 批处理的api WMIC学习体会有感第1/2页
- 批处理 API实现文件下载的代码第1/2页
- Lua教程(十七):C API简介
- 强制删除工具 xdelbox xdelbox1.5正式版下载
- 揪出交换机端口背后“凶手”导致网速太慢
- 电脑重启后突然检测不到硬盘的原因分析与解决办法
- C#中设计、使用Fluent API
- Google官方支持的NodeJS访问API,提供后台登录授权
- PQ分区出错! 巧用Ghost急速补救的绝妙办法
- 深入C++中API的问题详解
- 使用WindowsAPI实现播放PCM音频的方法
- 40余种刻录盘片详细对照分析介绍第1/2页
- node.js中的socket.io入门实例
- fullCalendar中文API官方文档