# SIOSocket
SIOSocket is simple interface for communicating with [socket.io 1.0](http://socket.io) from iOS.
## How to use
SIOSocket can be added as a CocodaPod, submodule, or standalone dependency to any iOS 7.0 (or greater) project.
```ruby
pod 'SIOSocket', '~> 0.2.0'
```
then...
```objc
#import <SIOSocket/SIOSocket.h>
// ...
[SIOSocket socketWithHost: @"http://localhost:3000" response: ^(SIOSocket *socket) {
self.socket = socket;
}];
```
or, in Swift...
```swift
// ...
SIOSocket.socketWithHost("http://localhost:3000") { (socket: SIOSocket) in
self.socket = socket
}
```
A full demo can be found over at [MegaBits/WorldPin](https://github.com/MegaBits/WorldPin)
## Types
#### `typedef NSArray SIOParameterArray`
An NSArray of these JSValue-valid objects:
- NSNull
- NSString
- NSNumber
- NSDictionary
- NSArray
- NSData
## Generators
#### `+ (void)socketWithHost:response:`
Generates a new `SIOSocket` object, begins its connection to the given host, and returns it as the sole parameter of the response block.
The host reachable at the given URL string should be running a valid instance of a socket.io server.
#### `+ (void)socketWithHost:reconnectAutomatically:attemptLimit:withDelay:maximumDelay:timeout:withTransports:response:`
- `reconnectAutomatically` whether to reconnect automatically (`YES`)
- `attemptLimit` number of times to attempt a reconnect (Infinite)
- `reconnectionDelay` how long to wait before attempting a new
reconnection (`1`)
- `maximumDelay` maximum amount of time to wait between
reconnections (`5`). Each attempt increases the reconnection by
the amount specified by `reconnectionDelay`.
- `timeout` connection timeout before an `onReconnectionError` event is emitted (`20`)
- `withTransports` specifies an array of transports for engine.io (default is 'polling', 'websocket').
## Properties
#### `void (^onConnect)()`
Called upon connecting.
#### `void (^onDisconnect)()`
Called upon a disconnection.
#### `void (^onError)(NSDictionary *errorInfo)`
Called upon a connection error.
#### `void (^onReconnect)(NSInteger numberOfAttempts)`
Called upon a successful reconnection.
#### `void (^onReconnectionAttempt)(NSInteger numberOfAttempts)`
Called upon an attempt to reconnect.
#### `void (^onReconnectionError)(NSDictionary *errorInfo)`
Called upon a reconnection attempt error.
## Responders
#### `-(void)on:callback:`
Binds the given `void (^)(SIOParameterArray *)` block, `function`, to the given `event`.
`function` is called upon a firing of `event`.
## Emitters
#### `-(void)emit:args:`
Fires the given `event` with then given SIOParameterArray as arguments.
## License
MIT
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
SIOSocket-master.zip (32个子文件)
SIOSocket-master
SocketIO
SocketIO.m 8KB
Source
SIOSocket.m 9KB
SIOSocket.h 2KB
socket.io.js.h 89KB
Info.plist 751B
LICENSE 1KB
.DS_Store 6KB
socket_tester
app.js 3KB
.gitignore 347B
SocketIO.xcodeproj
project.xcworkspace
contents.xcworkspacedata 153B
xcuserdata
linjp.xcuserdatad
WorkspaceSettings.xcsettings 332B
UserInterfaceState.xcuserstate 24KB
xcshareddata
SocketIO.xccheckout 1KB
project.pbxproj 20KB
xcuserdata
linjp.xcuserdatad
xcschemes
xcschememanagement.plist 574B
SocketIOHost.xcscheme 4KB
xcdebugger
Breakpoints_v2.xcbkptlist 91B
pcperini.xcuserdatad
xcschemes
xcschememanagement.plist 762B
SocketIOHost.xcscheme 4KB
SocketIO.xcscheme 2KB
xcdebugger
Breakpoints_v2.xcbkptlist 91B
README.md 3KB
SocketIOHost
main.m 289B
AppDelegate.h 232B
AppDelegate.m 2KB
Base.lproj
Main.storyboard 2KB
ViewController.h 170B
Images.xcassets
AppIcon.appiconset
Contents.json 333B
LaunchImage.launchimage
Contents.json 442B
Info.plist 1KB
ViewController.m 3KB
SIOSocket.podspec 540B
共 32 条
- 1
资源评论
- zhq1314zhq2017-02-04可以用,已经用上了
技术老宅
- 粉丝: 13
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功