hank
2016-12-13 6e1425f9ce40a8d178a0218e24bc37c7b01477bb
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
#import <Foundation/Foundation.h>
 
@class wax_server;
 
extern NSString * const TCPServerErrorDomain;
 
typedef enum {
    kTCPServerCouldNotBindToIPv4Address = 1,
    kTCPServerCouldNotBindToIPv6Address = 2,
    kTCPServerNoSocketsAvailable = 3,
} TCPServerErrorCode;
 
 
@protocol WaxServerDelegate
 
@optional
- (void)connected;
- (void)disconnected;
- (void)dataReceived:(NSData *)data;
 
@end
 
 
@interface wax_server : NSObject <NSStreamDelegate, NSNetServiceDelegate> {    
    CFSocketRef _ipv4socket;
    id<WaxServerDelegate> _delegate;
 
    NSNetService *_netService;
    NSInputStream *_inStream;
    NSOutputStream *_outStream;
}
    
@property(nonatomic, assign) id<WaxServerDelegate> delegate;
 
- (NSError *)startOnPort:(NSUInteger)port;
- (BOOL)stop;
- (BOOL)enableBonjourOnPort:(NSUInteger)port;
- (void)disableBonjour;
 
- (BOOL)send:(NSString *)output;
- (void)receive:(NSData *)output;
 
@end
 
// This is needed because the runtime doesn't automatically load protocols
@interface HACK_WAX_DELEGATE_IMPLEMENTOR : NSObject  <WaxServerDelegate> {}
@end