Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Node binary websocket streaming made easy for iOS

branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.md

Setup

Frameworks and Sources

Usage

Include StreamClient.h:

#import "StreamClient.h"

Create a client to a websocket, set to an instance variable then set a delegate and open:

- (void)viewWillAppear:(BOOL)animated {
    _client = [StreamClient clientWithAddress:[NSURL URLWithString:@"ws://filepiper.com/abcd"]];
    _client.delegate = self;
    [_client openClient];
}

Abide to StreamClientDelegate Protocol:

@protocol StreamClientDelegate <NSObject>
- (void)streamCreated: (BinaryStream *)stream withMeta: (id)meta;
@optional
- (void)clientOpened;
- (void)clientClosedWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean;
- (void)clientErred: (NSError *)error;
@end

When handling created streams, a delegate should follow the StreamDelegate protocol:

@protocol StreamDelegate <NSObject>
- (void)streamGotData: (id)data;
- (void)streamGotError: (NSError *)error;
- (void)streamEnded;
@end

Create, write to, listen to, end, and pipe streams as you please. Use the FileReadStream and FileWriteStream which are file interfaces following the same protocols as BinaryStreams:

@protocol WriteStream <NSObject>
- (void)write: (id)data;
- (void)end;
@optional
- (void)pause;  //TODO
- (void)resume; //TODO
@end

@protocol ReadStream <NSObject>
- (void)open;
@optional
- (void)pipe: (NSObject<WriteStream> *)destination;
- (void)pause;  //TODO
- (void)resume; //TODO
@end
Something went wrong with that request. Please try again.