SIOSocket is simple interface for communicating with socket.io 1.0 from iOS.
SIOSocket can be added as a CocodaPod, submodule, or standalone dependency to any iOS 7.0 (or greater) project.
pod 'SIOSocket', '~> 0.2.0'
then...
#import <SIOSocket/SIOSocket.h>
// ...
[SIOSocket socketWithHost: @"http://localhost:3000" response: ^(SIOSocket *socket) {
self.socket = socket;
}];
or, in Swift...
// ...
SIOSocket.socketWithHost("http://localhost:3000") { (socket: SIOSocket) in
self.socket = socket
}
A full demo can be found over at MegaBits/WorldPin
An NSArray of these JSValue-valid objects:
- NSNull
- NSString
- NSNumber
- NSDictionary
- NSArray
- NSData
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 byreconnectionDelay
.timeout
connection timeout before anonReconnectionError
event is emitted (20
)withTransports
specifies an array of transports for engine.io (default is 'polling', 'websocket').
Called upon connecting.
Called upon a disconnection.
Called upon a connection error.
Called upon a successful reconnection.
Called upon an attempt to reconnect.
Called upon a reconnection attempt error.
Binds the given void (^)(SIOParameterArray *)
block, function
, to the given event
.
function
is called upon a firing of event
.
Fires the given event
with then given SIOParameterArray as arguments.
MIT