Latest | 0.5.2 |
---|---|
Homepage | https://github.com/nathansizemore/hydrogen-objc |
License | MPL 2.0 |
Platforms | ios 7.0, requires ARC |
Authors |
[](https://travis-ci.org/Nathan Sizemore/hydrogen-objc)
Usage
// 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");
}
Installation
hydrogen-objc is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod "hydrogen-objc"
Author
Nathan Sizemore, [email protected]
License
hydrogen-objc is available under the MPL-2.0 license. See the LICENSE file for more info.
Latest podspec
{ "name": "hydrogen-objc", "version": "0.5.2", "summary": "Hydrogen Obj-C client", "description": "Obj-C hydrogen client.", "homepage": "https://github.com/nathansizemore/hydrogen-objc", "license": { "type": "MPL 2.0" }, "authors": { "Nathan Sizemore": "[email protected]" }, "source": { "git": "https://github.com/nathansizemore/hydrogen-objc.git", "tag": "0.5.2" }, "social_media_url": "https://twitter.com/nathansizemore", "platforms": { "ios": "7.0" }, "requires_arc": true, "source_files": "Pod/Classes/**/*", "resource_bundles": { "hydrogen-objc": [ "Pod/Assets/*.png" ] } }
Fri, 04 Mar 2016 14:13:03 +0000