2 // **********************************************************************
3 // The Cheat - A universal game cheater for Mac OS X
4 // (C) 2003-2005 Chaz McGarvey (BrokenZipper)
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)
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.
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.
21 #import <Cocoa/Cocoa.h>
26 #import "ServerChild.h"
29 @interface CheatServer
: NSObject
31 MySocket
*_socket
; // the socket that listens for connections
32 NSNetService
*_netService
; // for rendezvous broadcasting
34 int _port
; // port the socket is listening on
35 NSString
*_name
; // name the service is being broadcast as
37 NSMutableArray
*_children
; // the server spawns
43 - (id
)initWithDelegate
:(id
)delegate
;
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
;
52 // children are spawned by the server to handle remote sessions.
53 // they are instances of the ServerChild class.
55 - (NSArray
*)children
;
56 - (void)removeChildAtIndex
:(unsigned)index
;
62 - (NSString
*)broadcast
;
65 - (void)setDelegate
:(id
)delegate
;
70 @interface
NSObject ( CheatServerDelegate
)
72 // when the server dies while running... would this ever happen? I doubt it.
73 - (void)serverDisconnectedUnexpectedly
:(CheatServer
*)theServer
;
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
;
79 // a connection was made or lost with the server...
80 - (void)serverChildrenChanged
:(CheatServer
*)theServer
;