-
Notifications
You must be signed in to change notification settings - Fork 0
/
liar.m
37 lines (28 loc) · 966 Bytes
/
liar.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
#import <Foundation/Foundation.h>
#import <dispatch/dispatch.h>
#import <time.h>
#import "Game.h"
#import "GCDAsyncSocket.h"
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
srand(time(0));
Game *game = [[Game alloc] init];
dispatch_queue_t game_queue = dispatch_get_main_queue();
GCDAsyncSocket *socket = [[GCDAsyncSocket alloc] initWithDelegate:game delegateQueue:game_queue];
NSUserDefaults *options = [NSUserDefaults standardUserDefaults];
UInt16 port = [options integerForKey:@"port"];
if (!port) {
port = 35000;
}
NSError *err = NULL;
if (![socket acceptOnPort:port error:&err]) {
NSLog(@"accepting On port %d failed with error: %@", port, err);
exit(1);
}
NSLog(@"listening on port %d", port);
dispatch_main();
[socket release];
[game release];
[pool drain];
return 0;
}