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

Commit 14bec68

Browse files
MichaelScariapkyeck
authored andcommitted
fix unix timecode bug in handshake url. close #118.
1 parent b25510b commit 14bec68

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

SocketIO.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#endif
3939

4040
static NSString* kResourceName = @"socket.io";
41-
static NSString* kHandshakeURL = @"%@://%@%@/%@/1/?t=%d%@";
41+
static NSString* kHandshakeURL = @"%@://%@%@/%@/1/?t=%.0f%@";
4242
static NSString* kForceDisconnectURL = @"%@://%@%@/%@/1/xhr-polling/%@?disconnect";
4343

4444
float const defaultConnectionTimeout = 10.0f;
@@ -135,7 +135,8 @@ - (void) connectToHost:(NSString *)host
135135
// do handshake via HTTP request
136136
NSString *protocol = _useSecure ? @"https" : @"http";
137137
NSString *port = _port ? [NSString stringWithFormat:@":%d", _port] : @"";
138-
NSString *handshakeUrl = [NSString stringWithFormat:kHandshakeURL, protocol, _host, port, kResourceName, rand(), query];
138+
NSTimeInterval time = [[NSDate date] timeIntervalSince1970] * 1000;
139+
NSString *handshakeUrl = [NSString stringWithFormat:kHandshakeURL, protocol, _host, port, kResourceName, time, query];
139140

140141
DEBUGLOG(@"Connecting to socket with URL: %@", handshakeUrl);
141142
query = nil;

0 commit comments

Comments
 (0)