/Volumes/Plantain/MyDocuments/Projects/MacTrek/MacTrek/Comm/Communication.h

00001 //
00002 //  Communication.h
00003 //  MacTrek
00004 //
00005 //  Created by Aqua on 23/04/2006.
00006 //  Copyright 2006 __MyCompanyName__. All rights reserved.
00007 //
00008 
00009 #import <Cocoa/Cocoa.h>
00010 #import "PacketTypes.h"
00011 #import "Universe.h"
00012 #import "UdpStats.h"
00013 #import "LLNotificationCenter.h"
00014 #import "PingStats.h"
00015 #import "Luky.h"
00016 #include <unistd.h>
00017 
00018 #define COMM_UPDATES_PER_SECOND   5
00019 #define MAX_PORT_RETRY  10
00020 // set to yes to diagnose the udp 
00021 #define COMM_UDP_DIAG        NO
00022 #define COMM_MAX_PORT_RETRY  10 
00023 // other number blocks, like UDP Version
00024 #define COMM_SHORTVERSION    11
00025 // S_P2
00026 #define COMM_OLDSHORTVERSION 10                         
00027 
00028 @interface Communication : NSObject {
00029     int  commMode;         // COMM_TCP or COMM_UDP
00030     int  commStatus;
00031     int  commModeRequest;
00032     int  shortVersion;
00033     bool receiveShort;
00034     int  ghostSlot;
00035     FeatureList *fList;
00036     PingStats *pStats;
00037     Universe *universe;
00038     UdpStats *udpStats;
00039     LLNotificationCenter *notificationCenter;
00040 
00041 }
00042 - (id)initWithUniverse:(Universe*)newUniverse baseUdpPort:(int)basePort;
00043 // privates
00044 - (void)subscribeToNotifications;
00045 - (void) run;
00046 - (void) run:(id)sender;
00047 // get and set some cool stuff
00048 - (void) setMultiThreaded:(bool) multi;
00049 -(void) setPing:(bool) received withResponse:(int)response;
00050 -(FeatureList*) featureList;
00051 -(PingStats*) pingStats;
00052 -(UdpStats*)udpStats;
00053 -(int)ghostSlot;
00054 -(void)setGhostSlot:(int) slot;
00055 -(int)commStatus;
00056 -(void)setCommStatus:(int)status;
00057 -(int)commMode;
00058 -(void)setCommMode:(int)mode;
00059 -(int)commModeRequest;
00060 -(void)setCommModeRequest:(int)mode;
00061 -(int)shortVersion;
00062 -(void)setShortVersion:(int)ver;
00063 -(bool)receiveShort;
00064 -(void)setReceiveShort:(bool)rs;
00065 -(int) packetsReceived;
00066 -(void)increasePacketsReceived;
00067 -(void)decreasePacketsReceived;
00068 // control functions
00069 - (void) sendShortPacketWithId:(char) type;
00070 - (void) sendShortPacketNoForceWithId:(char) type state:(char) state;
00071 - (void) sendShortPacketWithId:(char) type boolState:(bool) state;
00072 - (void) sendShortPacketWithId:(char) type state:(char) state;
00073 - (void) sendServerPacketWithBuffer:(char*)buffer length:(int) size;
00074 // forcing routines
00075 - (void) resetForce;
00076 - (int) forceCheckFlags:(int) flag force:(int) force type:(char)type;
00077 - (int) forceCheckValue:(int) value force:(int) force type:(char) type;
00078 - (int) forceCheckTractFlag:(int) flag force:(int) force type:(char) type;
00079 - (void) checkForce;
00080 // these can be invoked by sending event messages
00081 -(void)cleanUp:(id)sender;
00082 -(void)readFromServer;
00083 -(void)readFromServer:(id)sender;
00084 -(void)periodicReadFromServer; // only if the thread has been started..
00085 // server messages
00086 - (void) sendSpeedReq:(NSNumber *) speed;  // int
00087 - (void) sendDockingReq:(NSNumber *) on;   // bool
00088 - (void) sendCloakReq:(NSNumber *) on;     // bool
00089 - (void) sendRefitReq:(NSNumber *) ship;   // char
00090 - (void) sendDirReq:(NSNumber *) dir;      // char
00091 - (void) sendPhaserReq:(NSNumber *) dir;   // char
00092 - (void) sendTorpReq:(NSNumber *) dir;     // char
00093 - (void) sendPlasmaReq:(NSNumber *) dir;   // char
00094 - (void) sendShieldReq:(NSNumber *) on;    // bool
00095 - (void) sendBombReq:(NSNumber *) bomb;    // bool
00096 - (void) sendBeamReq:(NSNumber *) up;      // bool
00097 - (void) sendRepairReq:(NSNumber *) on;    // bool
00098 - (void) sendOrbitReq:(NSNumber *) orbit;  // bool
00099 - (void) sendQuitReq:(id)sender;
00100 - (void) sendCoupReq:(id)sender;
00101 - (void) sendByeReq:(id)sender;
00102 - (void) sendPractrReq:(id)sender;
00103 - (void) sendDetonateReq:(id)sender;
00104 - (void) sendPlaylockReq:(NSNumber *) player;     // int
00105 - (void) sendPlanlockReq:(NSNumber *) planet;     // int
00106 - (void) sendResetStatsReq:(NSNumber *) verify;   // char
00107 - (void) sendWarReq:(NSNumber *) mask;            // char
00108 - (void) sendTractorOnReq:(NSNumber *) player;    // char
00109 - (void) sendTractorOffReq:(NSNumber *) player;   // char
00110 - (void) sendRepressorOnReq:(NSNumber *) player;  // char
00111 - (void) sendRepressorOffReq:(NSNumber *) player; // char
00112 - (void) sendTeamReq:(NSDictionary *)newTeam;    
00113 - (void) sendDetMineReq:(NSNumber *) torpId;      // int
00114 - (void) sendFeature:(NSDictionary *)newFeature;
00115 - (void) sendLoginReq:(NSDictionary *)login; 
00116 - (void) sendPingReq:(NSNumber *)start;           // bool
00117 - (void) sendServerPingResponse:(NSNumber *) number; // char
00118 - (void) sendMessage:(NSDictionary *)mess;
00119 - (void) sendUpdatePacket:(NSNumber *) updates_per_second; // int
00120 - (void) sendThreshold:(NSNumber*) threshold; // int
00121 - (void) sendDetonateMyTorpsReq:(id)sender;
00122 - (void) sendOptionsPacket:(id)sender;
00123 - (int) sendPickSocketReq;
00124 - (int) sendPickSocketReq:(NSNumber*) startAtPort; // int
00125 - (void) sendUdpReq:(NSNumber*) req; //char
00126 - (void) sendShortReq:(NSNumber*) req; //char
00127 - (void) sendUdpVerify:(id)sender;
00128 // setup communication
00129 - (bool) callServer:(NSString *) hostName port:(int) port;
00130 - (bool) startCommunicationThread; // call after successfull call of server
00131 - (bool) stopCommunicationThread;
00132 // applet routines
00133 - (bool) connectToServerUsingPort:(int) port;
00134 - (bool) connectToServerUsingPort:(int) port expectedHost:(NSString *) host; 
00135 - (bool) connectToServerUsingNextPort;
00136 - (int)  sendSocketVersionAndNumberReq:(int)port;
00137  // private routine, use sendUdpReq instead
00138 - (bool) openUdpConn;
00139 - (void) closeUdpConn;
00140 
00141 @end

Generated on Fri Jul 28 19:15:14 2006 for MacTrek by  doxygen 1.4.7