|
25 | 25 | #import "SocketIOPacket.h"
|
26 | 26 | #import "SocketIOJSONSerialization.h"
|
27 | 27 |
|
28 |
| -#import "SocketIOTransportWebsocket.h" |
29 |
| -#import "SocketIOTransportXHR.h" |
30 |
| - |
31 | 28 | #define DEBUG_LOGS 1
|
32 | 29 | #define DEBUG_CERTIFICATE 1
|
33 | 30 |
|
@@ -739,13 +736,25 @@ - (void) connectionDidFinishLoading:(NSURLConnection *)connection
|
739 | 736 | NSArray *transports = [t componentsSeparatedByString:@","];
|
740 | 737 | DEBUGLOG(@"transports: %@", transports);
|
741 | 738 |
|
742 |
| - if ([transports indexOfObject:@"websocket"] != NSNotFound) { |
| 739 | + static Class webSocketTransportClass; |
| 740 | + static Class xhrTransportClass; |
| 741 | + |
| 742 | + if(webSocketTransportClass == nil) { |
| 743 | + webSocketTransportClass = NSClassFromString(@"SocketIOTransportWebsocket"); |
| 744 | + } |
| 745 | + if(xhrTransportClass == nil) { |
| 746 | + xhrTransportClass = NSClassFromString(@"SocketIOTransportXHR"); |
| 747 | + } |
| 748 | + |
| 749 | + |
| 750 | + |
| 751 | + if (webSocketTransportClass != nil && [transports indexOfObject:@"websocket"] != NSNotFound) { |
743 | 752 | DEBUGLOG(@"websocket supported -> using it now");
|
744 |
| - _transport = [[SocketIOTransportWebsocket alloc] initWithDelegate:self]; |
| 753 | + _transport = [[webSocketTransportClass alloc] initWithDelegate:self]; |
745 | 754 | }
|
746 |
| - else if ([transports indexOfObject:@"xhr-polling"] != NSNotFound) { |
| 755 | + else if (xhrTransportClass != nil && [transports indexOfObject:@"xhr-polling"] != NSNotFound) { |
747 | 756 | DEBUGLOG(@"xhr polling supported -> using it now");
|
748 |
| - _transport = [[SocketIOTransportXHR alloc] initWithDelegate:self]; |
| 757 | + _transport = [[xhrTransportClass alloc] initWithDelegate:self]; |
749 | 758 | }
|
750 | 759 | else {
|
751 | 760 | DEBUGLOG(@"no transport found that is supported :( -> fail");
|
|
0 commit comments