Skip to content

Commit

Permalink
Merge pull request #244 from DyKnow/feature-dev
Browse files Browse the repository at this point in the history
2.0.2 Release
  • Loading branch information
Alex Billingsley committed Mar 18, 2016
2 parents 1554e96 + cf18dfd commit 0d87f44
Show file tree
Hide file tree
Showing 133 changed files with 4,641 additions and 8,709 deletions.
45 changes: 0 additions & 45 deletions CHANGES.md

This file was deleted.

23 changes: 23 additions & 0 deletions Example/Networking/ConnectionStatusConnection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// ConnectionStatusConnection.h
// SignalR.Client.ObjC Example
//
// Created by Alex Billingsley on 3/1/16.
//
//

#import "SignalR.h"

@interface ConnectionStatusConnection : SRHubConnection

+ (instancetype)sharedConnection;

- (void)ping;

- (void)setPongBlock:(void (^)(void))block;
- (void)setJoinedBlock:(void (^)(NSString *connectionId, NSString *when))block;
- (void)setRejoinedBlock:(void (^)(NSString *connectionId, NSString *when))block;
- (void)setLeaveBlock:(void (^)(NSString *connectionId, NSString *when))block;


@end
101 changes: 101 additions & 0 deletions Example/Networking/ConnectionStatusConnection.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
//
// ConnectionStatusConnection.m
// SignalR.Client.ObjC Example
//
// Created by Alex Billingsley on 3/1/16.
//
//

#import "ConnectionStatusConnection.h"

static NSString * const SRConnectionBaseURLString = @"http://abill-win10:9090/";

typedef void (^SRPongBlock)();
typedef void (^SRConnectionStatusBlock)(NSString *connectionId, NSString *when);

@interface ConnectionStatusConnection ()

@property (strong, nonatomic, readwrite) SRHubProxy * hub;

@property (readwrite, nonatomic, copy) SRPongBlock pong;
@property (readwrite, nonatomic, copy) SRConnectionStatusBlock joined;
@property (readwrite, nonatomic, copy) SRConnectionStatusBlock rejoined;
@property (readwrite, nonatomic, copy) SRConnectionStatusBlock leave;

@end

@implementation ConnectionStatusConnection

+ (instancetype)sharedConnection {
static ConnectionStatusConnection *_sharedConnection = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedConnection = [[ConnectionStatusConnection alloc] initWithURLString:SRConnectionBaseURLString];
});

return _sharedConnection;
}

- (instancetype)initWithURLString:(NSString *)url {
self = [super initWithURLString:url];
if (!self) {
return nil;
}

_hub = [self createHubProxy:@"statushub"];
[_hub on:@"pong" perform:self selector:@selector(handlePong)];
[_hub on:@"joined" perform:self selector:@selector(handleJoined:when:)];
[_hub on:@"rejoined" perform:self selector:@selector(handleRejoined:when:)];
[_hub on:@"leave" perform:self selector:@selector(handleLeave:when:)];

return self;
}

- (void)ping {
[self.hub invoke:@"ping" withArgs:@[] completionHandler:nil];
}

- (void)setPongBlock:(void (^)(void))block {
self.pong = block;
}

- (void)setJoinedBlock:(void (^)(NSString *connectionId, NSString *when))block; {
self.joined = block;
}

- (void)setRejoinedBlock:(void (^)(NSString *connectionId, NSString *when))block; {
self.rejoined = block;
}

- (void)setLeaveBlock:(void (^)(NSString *connectionId, NSString *when))block; {
self.leave = block;
}

#pragma mark -
#pragma mark Private

- (void)handlePong {
if(self.pong) {
self.pong();
}
}

- (void)handleJoined:(NSString *)connectionId when:(NSString *)when {
if(self.joined) {
self.joined(connectionId,when);
}
}

- (void)handleRejoined:(NSString *)connectionId when:(NSString *)when {
if(self.rejoined) {
self.rejoined(connectionId,when);
}
}

- (void)handleLeave:(NSString *)connectionId when:(NSString *)when {
if(self.leave) {
self.leave(connectionId,when);
}
}

@end
20 changes: 20 additions & 0 deletions Example/Networking/DrawingPadConnection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// DrawingPadConnection.h
// SignalR.Client.ObjC Example
//
// Created by Alex Billingsley on 3/3/16.
//
//

#import "SignalR.h"

@interface DrawingPadConnection : SRHubConnection

+ (instancetype)sharedConnection;

- (void)join;
- (void)draw:(NSString *)line completionHandler:(void (^)(id response, NSError *error))block;

- (void)setDrawBlock:(void (^)(NSDictionary *json))block;

@end
65 changes: 65 additions & 0 deletions Example/Networking/DrawingPadConnection.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// DrawingPadConnection.m
// SignalR.Client.ObjC Example
//
// Created by Alex Billingsley on 3/3/16.
//
//

#import "DrawingPadConnection.h"

static NSString * const SRConnectionBaseURLString = @"http://abill-win10:9090/";

typedef void (^SRConnectionDrawBlock)(NSDictionary *json);

@interface DrawingPadConnection ()

@property (strong, nonatomic, readwrite) SRHubProxy * hub;

@property (readwrite, nonatomic, copy) SRConnectionDrawBlock draw;

@end

@implementation DrawingPadConnection

+ (instancetype)sharedConnection {
static DrawingPadConnection *_sharedConnection = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedConnection = [[DrawingPadConnection alloc] initWithURLString:SRConnectionBaseURLString];
});

return _sharedConnection;
}

- (instancetype)initWithURLString:(NSString *)url {
self = [super initWithURLString:url];
if (!self) {
return nil;
}

_hub = [self createHubProxy:@"DrawingPad"];
[_hub on:@"draw" perform:self selector:@selector(handleDraw:)];

return self;
}

- (void)join {
[_hub invoke:@"join" withArgs:@[] completionHandler:nil];
}

- (void)draw:(NSString *)line completionHandler:(void (^)(id response, NSError *error))block; {
[_hub invoke:@"draw" withArgs:@[line] completionHandler:block];
}

- (void)setDrawBlock:(void (^)(NSDictionary *json))block {
self.draw = block;
}

- (void)handleDraw:(NSDictionary *)json {
if(self.draw) {
self.draw(json);
}
}

@end
20 changes: 20 additions & 0 deletions Example/Networking/MouseTrackingConnection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// MouseTrackingConnection.h
// SignalR.Client.ObjC Example
//
// Created by Alex Billingsley on 3/2/16.
//
//

#import "SignalR.h"

@interface MouseTrackingConnection : SRHubConnection

+ (instancetype)sharedConnection;

- (void)join;
- (void)move:(CGPoint)point completionHandler:(void (^)(id response, NSError *error))block;

- (void)setMoveBlock:(void (^)(NSString *connectionId, NSNumber *x, NSNumber *y))block;

@end
65 changes: 65 additions & 0 deletions Example/Networking/MouseTrackingConnection.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// MouseTrackingConnection.m
// SignalR.Client.ObjC Example
//
// Created by Alex Billingsley on 3/2/16.
//
//

#import "MouseTrackingConnection.h"

static NSString * const SRConnectionBaseURLString = @"http://abill-win10:9090/";

typedef void (^SRConnectionMouseMoveBlock)(NSString *connectionId, NSNumber *x, NSNumber *y);

@interface MouseTrackingConnection ()

@property (strong, nonatomic, readwrite) SRHubProxy * hub;

@property (readwrite, nonatomic, copy) SRConnectionMouseMoveBlock move;

@end

@implementation MouseTrackingConnection

+ (instancetype)sharedConnection {
static MouseTrackingConnection *_sharedConnection = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedConnection = [[MouseTrackingConnection alloc] initWithURLString:SRConnectionBaseURLString];
});

return _sharedConnection;
}

- (instancetype)initWithURLString:(NSString *)url {
self = [super initWithURLString:url];
if (!self) {
return nil;
}

_hub = [self createHubProxy:@"MouseTracking"];
[_hub on:@"move" perform:self selector:@selector(handleMove:x:y:)];

return self;
}

- (void)join {
[_hub invoke:@"join" withArgs:@[] completionHandler:nil];
}

- (void)move:(CGPoint)point completionHandler:(void (^)(id response, NSError *error))block; {
[_hub invoke:@"move" withArgs:@[@(point.x), @(point.y)] completionHandler:block];
}

- (void)setMoveBlock:(void (^)(NSString *connectionId, NSNumber *x, NSNumber *y))block {
self.move = block;
}

- (void)handleMove:(NSString *)connectionId x:(NSNumber *)x y:(NSNumber *)y {
if(self.move) {
self.move(connectionId,x,y);
}
}

@end
26 changes: 26 additions & 0 deletions Example/Networking/RawConnection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// RawConnection.h
// SignalR.Client.ObjC Example
//
// Created by Alex Billingsley on 3/1/16.
//
//

#import "SignalR.h"

@interface RawConnection : SRConnection

+ (instancetype)sharedConnection;

- (void)sendMessage:(NSString *)message completionHandler:(void (^)(id response, NSError *error))block;
- (void)broadcastMessage:(NSString *)message completionHandler:(void (^)(id response, NSError *error))block;
- (void)broadcastMessageExceptMe:(NSString *)message completionHandler:(void (^)(id response, NSError *error))block;

- (void)join:(NSString *)username completionHandler:(void (^)(id response, NSError *error))block;
- (void)sendMessage:(NSString *)message toUser:(NSString *)username completionHandler:(void (^)(id response, NSError *error))block;

- (void)joinGroup:(NSString *)group completionHandler:(void (^)(id response, NSError *error))block;
- (void)sendMessage:(NSString *)message toGroup:(NSString *)group completionHandler:(void (^)(id response, NSError *error))block;
- (void)leaveGroup:(NSString *)group completionHandler:(void (^)(id response, NSError *error))block;

@end

0 comments on commit 0d87f44

Please sign in to comment.