This repository was archived by the owner on May 14, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,8 @@ typedef enum {
39
39
SocketIOWebSocketClosed = -4 ,
40
40
SocketIOTransportsNotSupported = -5 ,
41
41
SocketIOHandshakeFailed = -6 ,
42
- SocketIODataCouldNotBeSend = -7
42
+ SocketIODataCouldNotBeSend = -7 ,
43
+ SocketIOUnauthorized = -8
43
44
} SocketIOErrorCodes;
44
45
45
46
Original file line number Diff line number Diff line change @@ -684,6 +684,8 @@ - (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)er
684
684
{
685
685
NSLog (@" ERROR: handshake failed ... %@ " , [error localizedDescription ]);
686
686
687
+ int errorCode = [error code ] == 403 ? SocketIOUnauthorized : SocketIOHandshakeFailed;
688
+
687
689
_isConnected = NO ;
688
690
_isConnecting = NO ;
689
691
@@ -692,7 +694,7 @@ - (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)er
692
694
forKey: NSUnderlyingErrorKey ] mutableCopy ];
693
695
694
696
NSError *err = [NSError errorWithDomain: SocketIOError
695
- code: SocketIOHandshakeFailed
697
+ code: errorCode
696
698
userInfo: errorInfo];
697
699
698
700
[_delegate socketIO: self onError: err];
Original file line number Diff line number Diff line change @@ -37,9 +37,9 @@ - (void) viewDidLoad
37
37
nil ];
38
38
NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties: properties];
39
39
NSArray *cookies = [NSArray arrayWithObjects: cookie, nil ];
40
-
40
+
41
41
socketIO.cookies = cookies;
42
-
42
+
43
43
// connect to the socket.io server that is running locally at port 3000
44
44
[socketIO connectToHost: @" localhost" onPort: 3000 ];
45
45
}
@@ -55,7 +55,7 @@ - (void) socketIODidConnect:(SocketIO *)socket
55
55
- (void ) socketIO : (SocketIO *)socket didReceiveEvent : (SocketIOPacket *)packet
56
56
{
57
57
NSLog (@" didReceiveEvent()" );
58
-
58
+
59
59
SocketIOCallback cb = ^(id argsData) {
60
60
NSDictionary *response = argsData;
61
61
// do something with response
@@ -69,7 +69,11 @@ - (void) socketIO:(SocketIO *)socket didReceiveEvent:(SocketIOPacket *)packet
69
69
70
70
- (void ) socketIO : (SocketIO *)socket onError : (NSError *)error
71
71
{
72
- NSLog (@" onError() %@ " , error);
72
+ if ([error code ] == SocketIOUnauthorized) {
73
+ NSLog (@" not authorized" );
74
+ } else {
75
+ NSLog (@" onError() %@ " , error);
76
+ }
73
77
}
74
78
75
79
You can’t perform that action at this time.
0 commit comments