hydrogen-objc 0.5.2

hydrogen-objc 0.5.2

测试已测试
Lang语言 Obj-CObjective C
许可证 自定义
发布最后发布2016年2月

Nathan Sizemore维护。



使用方法

// Initialize a client
//
// Initialization can be done with C function pointers, Obj-C delegates, or
// by passing in Obj-C blocks.
self.client = [[HydrogenClient alloc] initWithHydrogenDelegate:self];

// Connect to a hydrogen server
NSString *hostAddress = @"127.0.0.1";
uint16_t port = 1337;
[self.client connectToHostWithAddress:hostAddress andPort:port];

// Send a thing to server
const char *ping = "ping";
NSData *buffer = [[NSData alloc] initWithBytes:ping length:4];
[self.client write:buffer];

// Disconnect
[self.client disconnect];


// Hydrogen Protocol

// Called when connection to host has been established
- (void)onConnected
{
    NSLog(@"onConnected");
}

// Called when connection to host has been lost
- (void)onDisconnected
{
    NSLog(@"onDisconnected");
}

// Called when data is received from host
- (void)onDataReceived:(const uint8_t *)buffer withLen:(const size_t)len
{
    NSLog(@"onDataReceived");
    // Consumer is responsible for freeing buffer
}

// Called when an error has been encountered
- (void)onError:(HydrogenResult)error
{
    NSLog(@"onError");
}

安装

hydrogen-objc 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod "hydrogen-objc"

作者

Nathan Sizemore, [email protected]

许可证

hydrogen-objc 在 MPL-2.0 许可证下提供。有关更多信息,请参阅 LICENSE 文件。