SIOSocket 0.2.0

SIOSocket 0.2.0

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布上次发布2014年12月

MegaBits维护。



SIOSocket 0.2.0

  • Patrick Perini

SIOSocket是iOS与socket.io 1.0通信的简单接口。

如何使用

SIOSocket可以作为CocoaPod、子模块或独立依赖添加到任何iOS 7.0(或更高版本)项目中。

pod 'SIOSocket', '~> 0.2.0'

然后...

#import <SIOSocket/SIOSocket.h>

// ...
[SIOSocket socketWithHost: @"https://:3000" response: ^(SIOSocket *socket) {
    self.socket = socket;
}];

完整演示可在MegaBits/WorldPin中找到(当前仍需要SIOSocket v0.2.0)

类型

typedef NSArray SIOParameterArray

这些JSValue有效对象的NSArray

  • NSNull
  • NSString
  • NSNumber
  • NSDictionary
  • NSArray
  • NSData

生成器

+ (void)socketWithHost:response:

生成一个新的SIOSocket对象,开始连接到指定的主机,并将其作为响应块的唯一参数返回。

在给定的URL字符串中可达的主机应该运行有效的socket.io服务器实例。

+ (void)socketWithHost:reconnectAutomatically:attemptLimit:withDelay:maximumDelay:timeout:response:

  • reconnectAutomatically是否自动重新连接(《是》)
  • attemptLimit尝试重新连接的次数(无限)
  • reconnectionDelay尝试新的重新连接前的等待时间(1)
  • maximumDelay重新连接之间的最大等待时间(5)。每次尝试都会将重新连接的延迟增加由reconnectionDelay指定的数量。
  • timeout在发出`onReconnectionError`事件之前连接的超时时间(20)

属性

void(^onConnect)()

在连接时调用。

void(^onDisconnect)()

在断开连接时调用。

void(^onError)(NSDictionary *errorInfo)

在连接出错时调用。

void(^onReconnect)(NSInteger numberOfAttempts)

在成功重新连接时调用。

void (^onReconnectionAttempt)(NSInteger numberOfAttempts)

当尝试重新连接时被调用。

void (^onReconnectionError)(NSDictionary *errorInfo)

当重新连接尝试出现错误时被调用。

响应者

-(void(on)callback:

将给定的 void (^)(SIOParameterArray *) 块、function 绑定到给定的 event

functionevent 触发时被调用。

发射器

-(void)emit:args:

使用给定的 SIOParameterArray 参数触发给定的 event

许可证

MIT