]> Dogcows Code - chaz/thecheat/blob - CheatServer.h
The Cheat 1.2.3
[chaz/thecheat] / CheatServer.h
1
2 // **********************************************************************
3 // The Cheat - A universal game cheater for Mac OS X
4 // (C) 2003-2005 Chaz McGarvey (BrokenZipper)
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 1, or (at your option)
9 // any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 //
20
21 #import <Cocoa/Cocoa.h>
22 #import "ChazLog.h"
23
24 #import "MySocket.h"
25
26 #import "ServerChild.h"
27
28
29 @interface CheatServer : NSObject
30 {
31 MySocket *_socket; // the socket that listens for connections
32 NSNetService *_netService; // for rendezvous broadcasting
33
34 int _port; // port the socket is listening on
35 NSString *_name; // name the service is being broadcast as
36
37 NSMutableArray *_children; // the server spawns
38
39 id _delegate;
40 }
41
42 // initialization
43 - (id)initWithDelegate:(id)delegate;
44
45 // starting and stopping the server
46 // it will automatically be stopped on dealloc.
47 // pass nil for name to not broadcast.
48 - (BOOL)listenOnPort:(int)port broadcast:(NSString *)name;
49 - (void)stop;
50
51 // accessing children
52 // children are spawned by the server to handle remote sessions.
53 // they are instances of the ServerChild class.
54 - (int)childCount;
55 - (NSArray *)children;
56 - (void)removeChildAtIndex:(unsigned)index;
57
58 // accessors
59 - (BOOL)isListening;
60 - (NSString *)host;
61 - (int)port;
62 - (NSString *)broadcast;
63
64 - (id)delegate;
65 - (void)setDelegate:(id)delegate;
66
67 @end
68
69
70 @interface NSObject ( CheatServerDelegate )
71
72 // when the server dies while running... would this ever happen? I doubt it.
73 - (void)serverDisconnectedUnexpectedly:(CheatServer *)theServer;
74
75 // broadcast failed, this is much more likely to happen.
76 // note that the server will continue running.
77 - (void)server:(CheatServer *)theServer failedToBroadcastName:(NSString *)theName;
78
79 // a connection was made or lost with the server...
80 - (void)serverChildrenChanged:(CheatServer *)theServer;
81
82 @end
This page took 0.030378 seconds and 4 git commands to generate.