-
Notifications
You must be signed in to change notification settings - Fork 2
/
SISocketIOTransport.m
53 lines (38 loc) · 1.06 KB
/
SISocketIOTransport.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// SISocketIOTransport.m
// Socket.IO-iOS
//
// Created by masafumi yoshida on 2014/06/12.
// Copyright (c) 2014年 masafumi yoshida. All rights reserved.
//
#import "SISocketIOTransport.h"
#import "SISocketIOTransportPolling.h"
#import "SISocketIOTransportWebSocket.h"
@implementation SISocketIOTransport
- (id) init{
self = [super init];
if(self){
self.timestamp = 0;
self.readyStatus = SISocketIOTransportStatusClosed;
self.parser = [[SIEngineIOParser alloc] init];
}
return self;
}
-(NSString*)endpointURL{
NSString *url = [NSString stringWithFormat:@"%@://%@:%d/%@/?%@",[self protocol],[self host],[self port],[self path],[self query]];
NSLog(url);
return url;
}
-(void)send:(NSArray*)packets{
if(self.readyStatus == SISocketIOTransportStatusOpen){
[self write:packets];
}
}
-(void)close{
self.readyStatus = SISocketIOTransportStatusClosed;
[self.delegate onClose:self];
}
- (void) onPacket:(SIEngineIOPacket*)packet{
[self.delegate onPacket:self packet:packet];
}
@end