]> Dogcows Code - chaz/thecheat/blob - CheatServer.h
update contact information and project URL
[chaz/thecheat] / CheatServer.h
1
2 /*
3 * The Cheat - The legendary universal game trainer for Mac OS X.
4 * http://www.brokenzipper.com/trac/wiki/TheCheat
5 *
6 * Copyright (c) 2003-2011, Charles McGarvey et al.
7 *
8 * Distributable under the terms and conditions of the 2-clause BSD
9 * license; see the file COPYING for the legal text of the license.
10 */
11
12 #import <Cocoa/Cocoa.h>
13 #import "ChazLog.h"
14
15 #import "MySocket.h"
16
17 #import "ServerChild.h"
18
19
20 @interface CheatServer : NSObject
21 {
22 MySocket *_socket; // the socket that listens for connections
23 NSNetService *_netService; // for rendezvous broadcasting
24
25 int _port; // port the socket is listening on
26 NSString *_name; // name the service is being broadcast as
27
28 NSMutableArray *_children; // the server spawns
29
30 id _delegate;
31 }
32
33 // initialization
34 - (id)initWithDelegate:(id)delegate;
35
36 // starting and stopping the server
37 // it will automatically be stopped on dealloc.
38 // pass nil for name to not broadcast.
39 - (BOOL)listenOnPort:(int)port broadcast:(NSString *)name;
40 - (void)stop;
41
42 // accessing children
43 // children are spawned by the server to handle remote sessions.
44 // they are instances of the ServerChild class.
45 - (int)childCount;
46 - (NSArray *)children;
47 - (void)removeChildAtIndex:(unsigned)index;
48
49 // accessors
50 - (BOOL)isListening;
51 - (NSString *)host;
52 - (int)port;
53 - (NSString *)broadcast;
54
55 - (id)delegate;
56 - (void)setDelegate:(id)delegate;
57
58 @end
59
60
61 @interface NSObject ( CheatServerDelegate )
62
63 // when the server dies while running... would this ever happen? I doubt it.
64 - (void)serverDisconnectedUnexpectedly:(CheatServer *)theServer;
65
66 // broadcast failed, this is much more likely to happen.
67 // note that the server will continue running.
68 - (void)server:(CheatServer *)theServer failedToBroadcastName:(NSString *)theName;
69
70 // a connection was made or lost with the server...
71 - (void)serverChildrenChanged:(CheatServer *)theServer;
72
73 @end
This page took 0.035351 seconds and 4 git commands to generate.