测试已测试 | ✗ |
Lang语言 | Obj-CObjective C |
许可证 | MIT |
发布最后发布 | 2015年12月 |
由Clemens Hammerl 维护。
依赖 | |
SocketRocket | ~> 0.4 |
Base64 | ~> 1.0.1 |
适用于 iOS 的 Faye 客户端。该项目是对 pcrawfor 在此处创建的库的重写版本:https://github.com/pcrawfor/FayeObjC 优化了捕获错误,增加了订阅块,能够为频道设置扩展。增加了自动连接重连,等等...
self.client = [[MZFayeClient alloc] initWithURL:[NSURL URLWithString:@"ws://:9292/faye"]];
[self.client subscribeToChannel:@"/server" usingBlock:^(NSDictionary *message) {
NSLog(@"Server %@",message);
}];
[self.client subscribeToChannel:@"/browser" usingBlock:^(NSDictionary *message) {
NSLog(@"Browser %@",message);
}];
[self.client connect];
@protocol MZFayeClientDelegate <NSObject>
@optional
- (void)fayeClient:(MZFayeClient *)client didConnectToURL:(NSURL *)url;
- (void)fayeClient:(MZFayeClient *)client didDisconnectWithError:(NSError *)error;
- (void)fayeClient:(MZFayeClient *)client didUnsubscribeFromChannel:(NSString *)channel;
- (void)fayeClient:(MZFayeClient *)client didSubscribeToChannel:(NSString *)channel;
- (void)fayeClient:(MZFayeClient *)client didFailWithError:(NSError *)error;
- (void)fayeClient:(MZFayeClient *)client didFailDeserializeMessage:(NSDictionary *)message
withError:(NSError *)error;
- (void)fayeClient:(MZFayeClient *)client didReceiveMessage:(NSDictionary *)messageData fromChannel:(NSString *)channel;
@end
如果您想运行一个 Faye 服务器来测试客户端,您可以在那里找到所需的所有信息:http://faye.jcoglan.com/ 您还可以在 Server
目录下运行 faye.rb
文件。
gem install faye thin eventmachine
rackup faye.ru -s thin -E production
curl https://:9292/faye -d 'message={"channel":"/server", "data":"hello"}'
由 Square 维护的符合 WebSocket (RFC 6455) 的客户端库,https://github.com/square/SocketRocket
Objective-C 为 NSData 和 NSString 添加 Base64 功能 https://github.com/ekscrypto/Base64
MZFayeClient 需要 iOS 6.x 或更高版本。
MZFayeClient 使用 ARC。