Comm/ServerReader.h

00001 //-------------------------------------------
00002 // File:  ServerReader.h
00003 // Class: ServerReader
00004 // 
00005 // Created by Chris Lukassen 
00006 // Copyright (c) 2006 Luky Soft
00007 //-------------------------------------------
00008 //
00009 // Event based serverReader. Posts events when receiving an update.
00010 // sometimes the update is put in the userData. The following events are generated:
00011 //
00012 // communication:
00013 //
00014 //          SP_UDP_SWITCHED_TO_TCP
00015 //          SP_TCP_SWITCHED_TO_UDP  with userInfo: port 
00016 //          SP_SWITCHED_DENIED            
00017 //          SP_SWITCH_VERIFY
00018 //          SP_ASK_FOR_COMM_UPDATE
00019 //          SP_S_REPLY_SPK_OLD with userInfo: packetMode 
00020 //          SP_S_REPLY_SPK_VOFF with userInfo: commMessageToBeSent
00021 //          SP_S_REPLY_SPK_VONwith userInfo: commMessageToBeSent 
00022 //          SP_RESERVED with userInfo: sreserved
00023 //          SP_RSA_KEY with userInfo: data
00024 //          SP_PING with userInfo: pingStats  
00025 //          SP_FEATURE
00026 // login:
00027 //
00028 //          SP_QUEUE with userInfo: queueSize
00029 //          SP_PICKOK 
00030 //          SP_PICKNOK  
00031 //          SP_LOGIN_INVALID_SERVER
00032 //          SP_LOGIN_ACCEPTED with userInfo: me
00033 //          SP_LOGIN_NOT_ACCEPTED
00034 //          SP_MASK  with userInfo: teamMask
00035 //
00036 // messages:
00037 //
00038 //          SP_MESSAGE with userInfo: obj  
00039 //          SP_WARNING with userInfo: warning    
00040 //          SP_MOTD with userInfo: line
00041 //          SP_MOTD_SERVER_INFO with userInfo: line
00042 //          SP_S_MESSAGE with userInfo: message
00043 //          SPW_TEXTE with userInfo:message
00044 //          SPW_PHASER_HIT_TEXT with userInfo:message
00045 //          SPW_BOMB_INEFFECTIVE with userInfo:message
00046 //          SPW_BOMB_TEXT with userInfo:message
00047 //          SPW_BEAMUP_TEXT with userInfo:message
00048 //          SPW_BEAMUP2_TEXT with userInfo:message
00049 //          SPW_BEAMUPSTARBASE_TEXT with userInfo:message
00050 //          SPW_BEAMDOWNSTARBASE_TEXT with userInfo:message
00051 //          SPW_BEAMDOWNPLANET_TEXT with userInfo:message
00052 //          SPW_SBREPORT with userInfo:message
00053 //          SPW_ONEARG_TEXT with userInfo:message
00054 //          SPW_BEAM_D_PLANET_TEXT with userInfo:message
00055 //          SPW_BEAM_U_TEXT with userInfo:message
00056 //          SPW_LOCKPLANET_TEXT with userInfo:message
00057 //          SPW_LOCKPLAYER_TEXT with userInfo:message
00058 //          SPW_SBRANK_TEXT with userInfo:message
00059 //          SPW_SBDOCKREFUSE_TEXT with userInfo:message
00060 //          SPW_SBDOCKDENIED_TEXT with userInfo:message
00061 //          SPW_SBLOCKSTRANGER with userInfo:message
00062 //          SPW_SBLOCKMYTEAM with userInfo:message
00063 //          SPW_RCM_DMKILL with userInfo:rcm
00064 //          SPW_RCM_DMKILLP with userInfo:rcm
00065 //          SPW_RCM_DMBOMB with userInfo:rcm
00066 //          SPW_RCM_DMDEST with userInfo:rcm
00067 //          SPW_RCM_DMTAKE with userInfo:rcm
00068 //          SPW_RCM_DMGHOSTKILL with userInfo:rcm
00069 //          SPW_INLDRESUME with userInfo:message
00070 //          SPW_INLDTEXTE with userInfo:message
00071 //          SPW_STEXTE with userInfo:message
00072 //          SPW_SHORT_WARNING with userInfo:message
00073 //          SPW_STEXTE_STRING with userInfo:message
00074 //          SPW_UNKNOWN with userInfo:message                                        
00075 //
00076 // players:
00077 //
00078 //          SP_V_PLAYER with userInfo: player     
00079 //          SP_V_PLAYER with userInfo: player   
00080 //          SP_PLAYER_INFO with userInfo: player
00081 //          SP_KILLS with userInfo: player
00082 //          SP_PLAYER with userInfo: player 
00083 //          SP_PSTATUS with userInfo: player
00084 //          SP_HOSTILE with userInfo: player
00085 //          SP_STATS with userInfo: player
00086 //          SP_FLAGS with userInfo: player
00087 //          SP_S_KILLS with userInfo: player
00088 //          SP_S_STATS with userInfo: player
00089 //
00090 // new player:
00091 //
00092 //          SP_PL_LOGIN with userInfo: player
00093 //
00094 // you:
00095 //
00096 //          SP_YOU with userInfo: me  
00097 //          SP_STATUS with userInfo: status
00098 //          SP_S_YOU with userInfo: me                
00099 //          SP_S_YOU_SS with userInfo: me
00100 //
00101 // planets:
00102 //
00103 //          SP_V_PLANET with userInfo: planet
00104 //          SP_PLANET_LOC with userInfo: planet
00105 //
00106 // ships:
00107 //
00108 //          SP_SHIP_CAP with userInfo: ship
00109 //
00110 // weapons:
00111 //
00112 //          SP_V_TORP with userInfo: torp   
00113 //          SP_V_TORP_INFO with userInfo: torp
00114 //          SP_TORP_INFO with userInfo: torp
00115 //          SP_TORP with userInfo: torp         
00116 //          SP_PLASMA_INFO with userInfo: plasma  
00117 //          SP_PLASMA with userInfo: plasma
00118 //          SP_V_PHASER with userInfo: phaser
00119 //
00120 
00121 #import <Cocoa/Cocoa.h>
00122 @class Communication;
00123 #import "Communication.h"
00124 #import "Universe.h"
00125 #import "LLNotificationCenter.h"
00126 #import "ShortPacketWarningHandler.h"
00127 #import "PacketTypes.h"
00128 #import "MessageConstants.h"
00129 
00130 #define  SPWINSIDE       500
00131 #define  SHORT_WARNING    33
00132 #define  STEXTE_STRING    34
00133 
00134 // should be in seperate RSA file
00135 #define  RSA_KEY_SIZE     32
00136 
00137 @interface ServerReader : NSObject {
00138  
00139     bool motd_done;
00140     ShortPacketWarningHandler *swarningHandler;  // a short packet warning handler, it will be created as needed
00141     LLNotificationCenter *notificationCenter;
00142     Universe *universe;   // pointer to the universe (wauw!)
00143     Communication *communication; 
00144 } 
00145 
00146 - (id)initWithUniverse:(Universe*)universe communication:(Communication*)comm;
00147 - (NSData *) doRead;        // to be overwritten by TCP or UDP subclasses
00148 - (void) close;             // to be overwritten by TCP or UDP subclasses
00149 - (void) readFromServer;    // main routine
00150 - (bool) handlePacket:(int)ptype withSize:(int)size inBuffer:(char *)buffer;
00151 
00152 // plain C functions
00153 int shortFromPacket(char *buffer, int offset);
00154 
00155 // helper to cut of C strings
00156 - (NSString*) stringFromBuffer:(char*)buffer startFrom:(int)start maxLength:(int)max;
00157  
00158 @end

Generated on Sat Aug 26 21:14:10 2006 for MacTrek by  doxygen 1.4.7