3 * The Cheat - The legendary universal game trainer for Mac OS X.
4 * http://www.brokenzipper.com/trac/wiki/TheCheat
6 * Copyright (c) 2003-2011, Charles McGarvey et al.
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.
12 #import <Cocoa/Cocoa.h>
17 #import "ServerChild.h"
20 @interface CheatServer
: NSObject
22 MySocket
*_socket
; // the socket that listens for connections
23 NSNetService
*_netService
; // for rendezvous broadcasting
25 int _port
; // port the socket is listening on
26 NSString
*_name
; // name the service is being broadcast as
28 NSMutableArray
*_children
; // the server spawns
34 - (id
)initWithDelegate
:(id
)delegate
;
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
;
43 // children are spawned by the server to handle remote sessions.
44 // they are instances of the ServerChild class.
46 - (NSArray
*)children
;
47 - (void)removeChildAtIndex
:(unsigned)index
;
53 - (NSString
*)broadcast
;
56 - (void)setDelegate
:(id
)delegate
;
61 @interface
NSObject ( CheatServerDelegate
)
63 // when the server dies while running... would this ever happen? I doubt it.
64 - (void)serverDisconnectedUnexpectedly
:(CheatServer
*)theServer
;
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
;
70 // a connection was made or lost with the server...
71 - (void)serverChildrenChanged
:(CheatServer
*)theServer
;