Skip to content

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

Failed to load latest commit information.
BinaryStream.h
BinaryStream.m
ExampleAppDelegate.h
ExampleAppDelegate.m
ExampleViewController.h
ExampleViewController.m
FileReadStream.h
FileReadStream.m
FileWriteStream.h
FileWriteStream.m
NSData+SRB64Additions.h
NSData+SRB64Additions.m
README.md
SRWebSocket.h
SRWebSocket.m
StreamClient.h
StreamClient.m
StreamPacker.h
StreamPacker.m
StreamUnpacker.h
StreamUnpacker.m
base64.c
base64.h
main.m

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.