Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit 512c2dc

Browse files
committed
allow socket.io resource to be renamed from outside. close #80.
1 parent 5565423 commit 512c2dc

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

SocketIO.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,6 @@ typedef enum {
120120
- (void) sendEvent:(NSString *)eventName withData:(id)data andAcknowledge:(SocketIOCallback)function;
121121
- (void) sendAcknowledgement:(NSString*)pId withArgs:(NSArray *)data;
122122

123+
- (void) setResourceName:(NSString *)name;
124+
123125
@end

SocketIO.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ - (void) connectToHost:(NSString *)host
136136
NSString *protocol = _useSecure ? @"https" : @"http";
137137
NSString *port = _port ? [NSString stringWithFormat:@":%d", _port] : @"";
138138
NSString *handshakeUrl = [NSString stringWithFormat:kHandshakeURL, protocol, _host, port, kResourceName, rand(), query];
139-
139+
140140
DEBUGLOG(@"Connecting to socket with URL: %@", handshakeUrl);
141141
query = nil;
142142

@@ -148,7 +148,7 @@ - (void) connectToHost:(NSString *)host
148148
_handshake = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO];
149149
[_handshake scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
150150
[_handshake start];
151-
151+
152152
if (_handshake) {
153153
_httpRequestData = [NSMutableData data];
154154
}
@@ -250,6 +250,11 @@ - (void) sendAcknowledgement:(NSString *)pId withArgs:(NSArray *)data
250250
[self send:packet];
251251
}
252252

253+
- (void) setResourceName:(NSString *)name
254+
{
255+
kResourceName = [name copy];
256+
}
257+
253258
# pragma mark -
254259
# pragma mark private methods
255260

0 commit comments

Comments
 (0)