00001 /* 00002 * Network system UDP header 00003 * 00004 * This file is part of the "SoftPixel Engine" (Copyright (c) 2008 by Lukas Hermanns) 00005 * See "SoftPixelEngine.hpp" for license information. 00006 */ 00007 00008 #ifndef __SP_NETWORK_SYSTEM_UDP_H__ 00009 #define __SP_NETWORK_SYSTEM_UDP_H__ 00010 00011 00012 #include "Base/spStandard.hpp" 00013 00014 #ifdef SP_COMPILE_WITH_NETWORKSYSTEM 00015 00016 00017 #include "Framework/Network/spNetworkBaseUDP.hpp" 00018 #include "Framework/Network/spNetworkSystem.hpp" 00019 00020 00021 namespace sp 00022 { 00023 namespace network 00024 { 00025 00026 00028 class SP_EXPORT NetworkSystemUDP : public NetworkBaseUDP, public NetworkSystem 00029 { 00030 00031 public: 00032 00033 NetworkSystemUDP(); 00034 ~NetworkSystemUDP(); 00035 00036 /* === Functions === */ 00037 00038 io::stringc getDescription() const; 00039 00040 NetworkServer* hostServer(u16 Port = DEFAULT_PORT); 00041 NetworkServer* joinServer(const io::stringc &IPAddress, u16 Port = DEFAULT_PORT); 00042 00043 void disconnect(); 00044 00045 bool sendPacket(const NetworkPacket &Packet, NetworkMember* Receiver = 0); 00046 bool receivePacket(NetworkPacket &Packet, NetworkMember* &Sender); 00047 00048 bool popClientJoinStack(NetworkClient* &Client); 00049 bool popClientLeaveStack(NetworkClient* &Client); 00050 00051 NetworkMember* getMemberByAddress(const NetworkAddress &Address); 00052 00053 private: 00054 00055 /* === Functions === */ 00056 00057 bool bindToPort(u16 Port); 00058 00059 void sendClientAllServerInfos(const sockaddr_in &SenderAddr); 00060 00061 bool examineReceivedPacket(NetworkPacket &Packet, NetworkMember* &Sender, const sockaddr_in &SenderAddr); 00062 00063 void disconnectedByServer(); 00064 00065 }; 00066 00067 00068 } // /namespace network 00069 00070 } // /namespace sp 00071 00072 00073 #endif 00074 00075 #endif 00076 00077 00078 00079 // ================================================================================