#include <spNetworkSystem.hpp>
Public Member Functions | |
| virtual | ~NetworkSystem () |
| virtual io::stringc | getVersion () const |
| Returns the network system version. | |
| virtual io::stringc | getDescription () const =0 |
| Returns a description string for the network system. | |
| virtual NetworkServer * | hostServer (u16 Port=DEFAULT_PORT)=0 |
| Hosts a new network server. | |
| virtual NetworkServer * | joinServer (const io::stringc &IPAddress, u16 Port=DEFAULT_PORT)=0 |
| Joins the network server. | |
| virtual void | disconnect ()=0 |
| Disconnects from the current network server and closes the network session. | |
| virtual bool | sendPacket (const NetworkPacket &Packet, NetworkMember *Receiver=0)=0 |
| virtual bool | receivePacket (NetworkPacket &Packet, NetworkMember *&Sender)=0 |
| void | processPackets () |
| bool | waitForConnection () |
| virtual bool | popClientJoinStack (NetworkClient *&Client)=0 |
| virtual bool | popClientLeaveStack (NetworkClient *&Client)=0 |
| virtual NetworkMember * | getMemberByAddress (const NetworkAddress &Address)=0 |
| NetworkServer * | getServer () const |
| Returns pointer to the NetworkServer object. | |
| const std::list< NetworkClient * > & | getClientList () const |
| Returns the whole client object list. | |
| bool | isSessionRunning () const |
| Returns true if a network session is currently running, i.e. a server has been opened or joined. | |
| bool | isConnected () const |
| Returns true if a network session is currently connected, i.e. a server has been opened or an external joined server has accepted the connection. | |
| bool | isServer () const |
| Returns true if a network server was opened by this computer (in this case this network system is the server). | |
Static Public Member Functions | |
| static io::stringc | getHostIPAddress (const io::stringc &HostName) |
| static io::stringc | getOfficialHostName (const io::stringc &HostName) |
| Returns the official host name (e.g. "www.google.com" to "www.l.google.com"). | |
| static std::list< io::stringc > | getHostIPAddressList (const io::stringc &HostName) |
| static std::list< io::stringc > | getNetworkMembers () |
| static std::list< SNetworkAdapter > | getNetworkAdapters () |
| Returns all network adapters on the local computer. | |
| static std::list< io::stringc > | getBroadcastIPList () |
Protected Member Functions | |
| NetworkSystem () | |
| void | createWinSock () |
| void | deleteWinSock () |
| void | registerMember (NetworkMember *Member) |
| NetworkMember * | getMemberByAddress (const sockaddr_in &SenderAddr) |
| NetworkClient * | createClient (const NetworkAddress &ClientAddr) |
| void | deleteClient (NetworkClient *Client) |
| void | closeNetworkSession () |
Protected Attributes | |
| WSADATA | WinSock_ |
| NetworkServer * | Server_ |
| std::list< NetworkClient * > | ClientList_ |
| std::list< NetworkClient * > | ClientJointStack_ |
| std::list< NetworkClient * > | ClientLeaveStack_ |
| std::map< u64, NetworkMember * > | MemberMap_ |
| bool | isSessionRunning_ |
| bool | isConnected_ |
| bool | hasOpenedServer_ |
Use this class for your network system interface.
| virtual sp::network::NetworkSystem::~NetworkSystem | ( | ) | [virtual] |
| sp::network::NetworkSystem::NetworkSystem | ( | ) | [protected] |
| void sp::network::NetworkSystem::closeNetworkSession | ( | ) | [protected] |
| NetworkClient* sp::network::NetworkSystem::createClient | ( | const NetworkAddress & | ClientAddr | ) | [protected] |
| void sp::network::NetworkSystem::createWinSock | ( | ) | [protected] |
| void sp::network::NetworkSystem::deleteClient | ( | NetworkClient * | Client | ) | [protected] |
| void sp::network::NetworkSystem::deleteWinSock | ( | ) | [protected] |
| virtual void sp::network::NetworkSystem::disconnect | ( | ) | [pure virtual] |
Disconnects from the current network server and closes the network session.
Implemented in sp::network::NetworkSystemTCP, and sp::network::NetworkSystemUDP.
| static std::list<io::stringc> sp::network::NetworkSystem::getBroadcastIPList | ( | ) | [static] |
Returns a unique list of all available broadcast IP addresses. This depends on the count of network adapters.
| const std::list<NetworkClient*>& sp::network::NetworkSystem::getClientList | ( | ) | const [inline] |
Returns the whole client object list.
| virtual io::stringc sp::network::NetworkSystem::getDescription | ( | ) | const [pure virtual] |
Returns a description string for the network system.
Implemented in sp::network::NetworkSystemTCP, and sp::network::NetworkSystemUDP.
| static io::stringc sp::network::NetworkSystem::getHostIPAddress | ( | const io::stringc & | HostName | ) | [static] |
Returns the IP address of the specified host name.
| HostName,: | Specifies the host name (or rather local PC name). |
| static std::list<io::stringc> sp::network::NetworkSystem::getHostIPAddressList | ( | const io::stringc & | HostName | ) | [static] |
Gets all IP addresses of the specified host name.
| HostName,: | Specifies the host name (or rather local PC name): |
| virtual NetworkMember* sp::network::NetworkSystem::getMemberByAddress | ( | const NetworkAddress & | Address | ) | [pure virtual] |
Returns a pointer to the network member with the given address or 0 (null) if there is no member with this address.
Implemented in sp::network::NetworkSystemTCP, and sp::network::NetworkSystemUDP.
| NetworkMember* sp::network::NetworkSystem::getMemberByAddress | ( | const sockaddr_in & | SenderAddr | ) | [protected] |
| static std::list<SNetworkAdapter> sp::network::NetworkSystem::getNetworkAdapters | ( | ) | [static] |
Returns all network adapters on the local computer.
| static std::list<io::stringc> sp::network::NetworkSystem::getNetworkMembers | ( | ) | [static] |
Gets all network member host names (or rather local PC names).
| static io::stringc sp::network::NetworkSystem::getOfficialHostName | ( | const io::stringc & | HostName | ) | [static] |
Returns the official host name (e.g. "www.google.com" to "www.l.google.com").
| NetworkServer* sp::network::NetworkSystem::getServer | ( | ) | const [inline] |
Returns pointer to the NetworkServer object.
| virtual io::stringc sp::network::NetworkSystem::getVersion | ( | ) | const [virtual] |
Returns the network system version.
| virtual NetworkServer* sp::network::NetworkSystem::hostServer | ( | u16 | Port = DEFAULT_PORT |
) | [pure virtual] |
Hosts a new network server.
Implemented in sp::network::NetworkSystemTCP, and sp::network::NetworkSystemUDP.
| bool sp::network::NetworkSystem::isConnected | ( | ) | const [inline] |
Returns true if a network session is currently connected, i.e. a server has been opened or an external joined server has accepted the connection.
| bool sp::network::NetworkSystem::isServer | ( | ) | const [inline] |
Returns true if a network server was opened by this computer (in this case this network system is the server).
| bool sp::network::NetworkSystem::isSessionRunning | ( | ) | const [inline] |
Returns true if a network session is currently running, i.e. a server has been opened or joined.
| virtual NetworkServer* sp::network::NetworkSystem::joinServer | ( | const io::stringc & | IPAddress, | |
| u16 | Port = DEFAULT_PORT | |||
| ) | [pure virtual] |
Joins the network server.
Implemented in sp::network::NetworkSystemTCP, and sp::network::NetworkSystemUDP.
| virtual bool sp::network::NetworkSystem::popClientJoinStack | ( | NetworkClient *& | Client | ) | [pure virtual] |
Pops a client from the join-stack. Use this to determine when a new client joined the server.
| Client,: | Specifies where the client pointer is to be stored. |
// Example: NetworkClient* NewClient; while (spNetwork->popClientJoinStack(NewClient)) AddNewClientToGame(NewClient);
Implemented in sp::network::NetworkSystemTCP, and sp::network::NetworkSystemUDP.
| virtual bool sp::network::NetworkSystem::popClientLeaveStack | ( | NetworkClient *& | Client | ) | [pure virtual] |
Pops a client from the leave-stack. Use this to determine when a client left the server.
| Client,: | Specifies where the client pointer is to be stored. |
// Example: NetworkClient* LeftClient; while (spNetwork->popClientLeaveStack(LeftClient)) RemoveOldClientFromGame(LeftClient);
Implemented in sp::network::NetworkSystemTCP, and sp::network::NetworkSystemUDP.
| void sp::network::NetworkSystem::processPackets | ( | ) |
Processes each incomming network packet only for internal purposes. This is equivalent to the following code snippet:
NetworkPacket Packet;
NetworkMember* Sender = 0;
while (spNetwork->receivePacket(Packet, Sender));
| virtual bool sp::network::NetworkSystem::receivePacket | ( | NetworkPacket & | Packet, | |
| NetworkMember *& | Sender | |||
| ) | [pure virtual] |
Receives a network packet and returns the sender.
| Packet,: | Returns a new incomming message. | |
| Sender,: | Returns the sender. |
Implemented in sp::network::NetworkSystemTCP, and sp::network::NetworkSystemUDP.
| void sp::network::NetworkSystem::registerMember | ( | NetworkMember * | Member | ) | [protected] |
| virtual bool sp::network::NetworkSystem::sendPacket | ( | const NetworkPacket & | Packet, | |
| NetworkMember * | Receiver = 0 | |||
| ) | [pure virtual] |
Sends a network packet to the given network member.
| Packet,: | Specifies the network packet which is to be send. | |
| Receiver,: | Specifies the network member which is to receive the packet. By default 0 which means that each member gets the packet. |
Implemented in sp::network::NetworkSystemTCP, and sp::network::NetworkSystemUDP.
| bool sp::network::NetworkSystem::waitForConnection | ( | ) |
Processes each incomming netowrk packet and retuns true once the server accepted the connection. Use this as a UDP client after joining a server.
std::list<NetworkClient*> sp::network::NetworkSystem::ClientJointStack_ [protected] |
std::list<NetworkClient*> sp::network::NetworkSystem::ClientLeaveStack_ [protected] |
std::list<NetworkClient*> sp::network::NetworkSystem::ClientList_ [protected] |
bool sp::network::NetworkSystem::hasOpenedServer_ [protected] |
bool sp::network::NetworkSystem::isConnected_ [protected] |
bool sp::network::NetworkSystem::isSessionRunning_ [protected] |
std::map<u64, NetworkMember*> sp::network::NetworkSystem::MemberMap_ [protected] |
NetworkServer* sp::network::NetworkSystem::Server_ [protected] |
WSADATA sp::network::NetworkSystem::WinSock_ [protected] |
1.7.1