<commit_before># Hydna

This the official Objective-C bindings for hydna (in a pod) https://www.hydna.com for full documentation of our API please go to https://www.hydna.com/documentation

Get a free hydna domain at https://www.hydna.com/account/create/

## Usage

Import:

    #import "HYChannel.h"

Implement the following optional **<HYChannelDelegate>** methods:

    - (void)channelOpen:(HYChannel *)sender message:(NSString *)message;

    - (void)channelClose:(HYChannel *)sender error:(HYChannelError *)error;

    - (void)channelMessage:(HYChannel *)sender data:(HYChannelData *)data;

    - (void)channelSignal:(HYChannel *)sender data:(HYChannelSignal)data;

Opening a channel:

    HYChannel * channel = [[HYChannel alloc] init];
    [channel setDelegate:self];
    @try {
        [self.channel connect:@"yourdomain.hydna.net" mode:READWRITEEMIT token:@"<PASSWORD>"];
    }
    @catch (NSException *exception) {
        NSLog(@"Error: %@", exception.reason);
    }

Sending some data:
    
    [channel writeString:@"Hello World"];

Sending a signal:

    [channel emitString:@"Hello Signal"];

Receiving data:
    
    - (void)channelMessage:(HYChannel *)sender data:(HYChannelData *)data
    {
        NSData *payload = [data content];

        if ([data isUtf8Content]) {
            NSString *message = [[NSString alloc] initWithData:payload encoding:NSUTF8StringEncoding];
            NSLog(@"%@", message);
        } else {
            NSLog(@"Binary data received");
        }
    }

Receiving signal:

    - (void)channelSignal:(HYChannel *)sender data:(HYChannelSignal *)data
    {
        NSData *payload = [data content];

        if ([data isUtf8Content]) {
            NSString *message = [[NSString alloc] initWithData:payload encoding:NSUTF8StringEncoding];
            NSLog(@"%@", message);
        } else {
            NSLog(@"Binary data received");
        }
    }

Handling close:

    - (void)channelClose:(HYChannel *)sender error:(HYChannelError *)error
    {
        if (error.wasDenied) {
            NSLog(@"Connection to hydna was denied: %@", error.reason);
        } else if (error.wasClean) {
            NSLog(@"Connection closed by user or by behavior");
        } else {
            NSLog("Error: %@", error.reason);
        }
    }


# Requirements

ios: 5 +
osx: 10.7 +

## Installation

hydna is available through [CocoaPods](http://cocoapods.org), to install
it simply add the following line to your Podfile:

    pod "Hydna"

## Author

<NAME>, <EMAIL>

## License

hydna is available under the MIT license. See the LICENSE file for more info.
<commit_msg>cleanup example<commit_after># Hydna

This the official Objective-C bindings for hydna (in a pod) https://www.hydna.com for full documentation of our API please go to https://www.hydna.com/documentation

Get a free hydna domain at https://www.hydna.com/account/create/

## Usage

Import:

    #import "HYChannel.h"

Implement the following optional **<HYChannelDelegate>** methods:

    - (void)channelOpen:(HYChannel *)sender message:(NSString *)message;

    - (void)channelClose:(HYChannel *)sender error:(HYChannelError *)error;

    - (void)channelMessage:(HYChannel *)sender data:(HYChannelData *)data;

    - (void)channelSignal:(HYChannel *)sender data:(HYChannelSignal)data;

Opening a channel:

    HYChannel * channel = [[HYChannel alloc] init];
    [channel setDelegate:self];
    @try {
        [self.channel connect:@"yourdomain.hydna.net" mode:READWRITEEMIT token:@"optionaltoken"];
    }
    @catch (NSException *exception) {
        NSLog(@"Error: %@", exception.reason);
    }

Sending some data:
    
    [channel writeString:@"Hello World"];

Sending a signal:

    [channel emitString:@"Hello Signal"];

Receiving data:
    
    - (void)channelMessage:(HYChannel *)sender data:(HYChannelData *)data
    {
        NSData *payload = [data content];
        if ([data isUtf8Content]) {
            NSString *message = [[NSString alloc] initWithData:payload encoding:NSUTF8StringEncoding];
            NSLog(@"%@", message);
        } else {
            NSLog(@"Binary data received");
        }
    }

Receiving signal:

    - (void)channelSignal:(HYChannel *)sender data:(HYChannelSignal *)data
    {
        NSData *payload = [data content];
        if ([data isUtf8Content]) {
            NSString *message = [[NSString alloc] initWithData:payload encoding:NSUTF8StringEncoding];
            NSLog(@"%@", message);
        } else {
            NSLog(@"Binary data received");
        }
    }

Handling close:

    - (void)channelClose:(HYChannel *)sender error:(HYChannelError *)error
    {
        if (error.wasDenied) {
            NSLog(@"Connection to hydna was denied: %@", error.reason);
        } else if (error.wasClean) {
            NSLog(@"Connection closed by user or by behavior");
        } else {
            NSLog("Error: %@", error.reason);
        }
    }


# Requirements

ios: 5 +
osx: 10.7 +

## Installation

hydna is available through [CocoaPods](http://cocoapods.org), to install
it simply add the following line to your Podfile:

    pod "Hydna"

## Author

<NAME>, <EMAIL>

## License

hydna is available under the MIT license. See the LICENSE file for more info.

{'fraction_non_alphanumeric': 0.1291435140831577, 'fraction_numerical': 0.003065721402567542, 'mean_word_length': 3.040247678018576, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 6, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5719383', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1499, 'n_words': 413}