Skip to content

Commit

Permalink
use const strings instead of literals
Browse files Browse the repository at this point in the history
  • Loading branch information
vasily-popov committed Sep 28, 2017
1 parent 65b519a commit 4115758
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
9 changes: 9 additions & 0 deletions Source/VPSocketIOClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ typedef enum : NSUInteger {
VPSocketIOClientStatusConnected= 0x4
} VPSocketIOClientStatus;


extern NSString *const kSocketEventConnect;
extern NSString *const kSocketEventDisconnect;
extern NSString *const kSocketEventError;
extern NSString *const kSocketEventReconnect;
extern NSString *const kSocketEventReconnectAttempt;
extern NSString *const kSocketEventStatusChange;


typedef void (^VPSocketIOVoidHandler)(void);
typedef void (^VPSocketAnyEventHandler)(VPSocketAnyEvent*event);

Expand Down
20 changes: 14 additions & 6 deletions Source/VPSocketIOClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
} VPSocketClientEvent;


NSString *const kSocketEventConnect = @"connect";
NSString *const kSocketEventDisconnect = @"disconnect";
NSString *const kSocketEventError = @"error";
NSString *const kSocketEventReconnect = @"reconnect";
NSString *const kSocketEventReconnectAttempt = @"reconnectAttempt";
NSString *const kSocketEventStatusChange = @"statusChange";


@interface VPSocketIOClient() <VPSocketEngineClient>
{
int currentAck;
Expand Down Expand Up @@ -184,12 +192,12 @@ -(void)setDefaultValues {
_waitingPackets = [[NSMutableArray alloc] init];


eventStrings =@{ @(VPSocketClientEventConnect) : @"connect",
@(VPSocketClientEventDisconnect) : @"disconnect",
@(VPSocketClientEventError) : @"error",
@(VPSocketClientEventReconnect) : @"reconnect",
@(VPSocketClientEventReconnectAttempt) : @"reconnectAttempt",
@(VPSocketClientEventStatusChange) : @"statusChange"};
eventStrings =@{ @(VPSocketClientEventConnect) : kSocketEventConnect,
@(VPSocketClientEventDisconnect) : kSocketEventDisconnect,
@(VPSocketClientEventError) : kSocketEventError,
@(VPSocketClientEventReconnect) : kSocketEventReconnect,
@(VPSocketClientEventReconnectAttempt) : kSocketEventReconnectAttempt,
@(VPSocketClientEventStatusChange) : kSocketEventStatusChange};


statusStrings = @{ @(VPSocketIOClientStatusNotConnected) : @"notconnected",
Expand Down
4 changes: 3 additions & 1 deletion VPSocketIO/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ -(void)socketExample{



[socket on:@"connect" callback:^(NSArray *array, VPSocketAckEmitter *emitter) {


[socket on:kSocketEventConnect callback:^(NSArray *array, VPSocketAckEmitter *emitter) {
NSLog(@"!!!!socket connected");
}];

Expand Down

0 comments on commit 4115758

Please sign in to comment.