00001 #ifndef _GSSIMPLECONNECT_H 00002 #define _GSSIMPLECONNECT_H 00003 #include "define.h" 00004 00005 class clGSConnect; 00006 class clConnectElem; 00007 class clConnectList; 00008 class clTCPClient; 00009 class clUNIXClient; 00010 00011 //=================================================================================================== 00012 class clSimpleClient 00013 { 00014 private: 00015 clConnectElem* m_pstConnectElem; 00016 GSchar m_szAddress[129]; 00017 00018 public: 00019 /* Constructor/Destructor */ 00020 clSimpleClient( GSint lAliveDuring, GSint lRcvTimeout, 00021 GSint iUDPSndBuf = 0, GSint iUDPRcvBuf = 0); 00022 ~clSimpleClient(); 00023 00024 /* To connect on a peer address using TCP */ 00025 GSbool ConnectHost(GSchar *szHost, GSushort lPort); 00026 00027 #ifdef LINUX 00028 /* To connect to a peer UNIX process */ 00029 GSbool ConnectUNIXHost(GSchar *sSockPipe); 00030 #endif // LINUX 00031 00032 /* Disconnect from peer address */ 00033 GSbool Disconnect(GSvoid); 00034 00035 /* Update messages receive/send */ 00036 GSbool CheckConnection(GSvoid); 00037 00038 /* To send a message (put in the send queue) (Priority : 0-31) */ 00039 GSbool SendGuaranteed( GSubyte ucType, GSubyte ucPriority, GSvoid *pvMessage, GSint lMsgSize); 00040 GSbool SendLostable( GSubyte ucType, GSubyte ucPriority, GSvoid *pvMessage, GSint lMsgSize); 00041 00042 /* To read a message (from the received queue) */ 00043 GSvoid* ReadGuaranteed( GSubyte& rucType, GSint& rlSize); 00044 GSvoid* ReadLostable( GSubyte& rucType, GSint& rlSize); 00045 00046 /* IP management */ 00047 GSchar* GetPeerIPAddress(GSvoid); 00048 GSchar* GetLocalIPAddress(GSvoid); 00049 00050 // Checks to see if the UDP connection has been established. 00051 // You must call CheckConnection, ReadGuaranteed and ReadLostable 00052 // between calls to IsUDPConnected to generate and send internal messages 00053 // that establish the UDP connection 00054 GSbool IsUDPConnected(); 00055 }; 00056 00057 //=================================================================================================== 00058 class clSimpleServer 00059 { 00060 private: 00061 clConnectList* m_pstConnectList; 00062 00063 GSint m_lConnectedMode; 00064 GSint m_lStillAliveDuring; 00065 GSint m_lRcvDuring; 00066 GSchar m_szAddress[129]; 00067 00068 public: 00069 clSimpleServer( GSint lAliveDuring, GSint lRcvTimeout, 00070 GSint iUDPSndBuf = 0, GSint iUDPRcvBuf = 0); 00071 ~clSimpleServer(); 00072 00073 /* Return the port reserved */ 00074 GSbool ReservePort(GSushort lPort); 00075 00076 #ifdef LINUX 00077 /* Puts the UNIX server into listening mode (UNIX Sockets) */ 00078 GSbool OpenSocket(GSchar *p_strSockPipe); 00079 #endif // LINUX 00080 00081 /* Return the ID of the new connection */ 00082 GSint AcceptConnection(GSvoid); 00083 00084 /* Return the ID of the element disconnected */ 00085 GSint CheckDisconnection(GSvoid); 00086 00087 /* To disconnect an element */ 00088 GSbool DisconnectElement(GSint lId); 00089 00090 /* To send a message (put in the send queue) (Priority : 0-31) */ 00091 GSbool SendGuaranteed( GSint lId, GSubyte ucType, GSubyte ucPriority, GSvoid *pvMessage, GSint lMsgSize); 00092 GSbool SendLostable( GSint lId, GSubyte ucType, GSubyte ucPriority, GSvoid *pvMessage, GSint lMsgSize); 00093 GSbool SendGuaranteedToAll( GSubyte ucType, GSubyte ucPriority, GSvoid *pvMessage, GSint lMsgSize); 00094 GSbool SendLostableToAll( GSubyte ucType, GSubyte ucPriority, GSvoid *pvMessage, GSint lMsgSize); 00095 00096 /* To read a message (from the received queue) */ 00097 GSvoid* ReadGuaranteed( GSint& rlId, GSubyte& rucType, GSint& rlSize); 00098 GSvoid* ReadLostable( GSint& rlId, GSubyte& rucType, GSint& rlSize); 00099 00100 /* IP management */ 00101 GSchar* GetPeerIPAddress(GSint lId); 00102 00103 // Checks to see if the UDP connection has been established for that 00104 // connection ID. You must call CheckDisconnection, ReadGuaranteed and 00105 // ReadLostable between calls to IsUDPConnected to generate and send internal 00106 // messages that establish the UDP connection 00107 GSbool IsUDPConnected(GSint iID); 00108 }; 00109 00110 #endif // _GSSIMPLECONNECT_H
Ubi.com GameService SDK - ©UbiSoft Entertainment 2002
GameService development team