Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

Networking Class Reference

#include <networking.h>

List of all members.

Public Member Functions

const string GetClientHost (const uint index)
const uint GetClientNum ()
const uint GetClientMax ()
const OPENCITY_NET_CODE GetMachineRole ()
const uint GetPingTimeout ()
const uint GetServerNum ()
const string GetServerHost (const uint index)
const string GetVersion ()
const string GetProtocol ()
const OPENCITY_NET_CODE Accept (uint &rid)
const OPENCITY_NET_CODE Reject (const uint id)
const OPENCITY_NET_CODE StartServer (const OC_SUINT port=OC_NET_SERVER_PORT)
const OPENCITY_NET_CODE StopServer ()
const OPENCITY_NET_CODE ProcessServerData ()
const OPENCITY_NET_CODE Open (const string serverHost, const OC_SUINT port=OC_NET_SERVER_PORT)
const OPENCITY_NET_CODE Close ()
const OPENCITY_NET_CODE Close (ClientIter i)
const OPENCITY_NET_CODE Send (const void *const data, const uint len)
const OPENCITY_NET_CODE Send (const void *const data, const uint len, const uint cid)
const OPENCITY_NET_CODE SendMessage (NetMessage &rMsg)
const OPENCITY_NET_CODE SendMessage (NetMessage &rMsg, const uint cid)
const OPENCITY_NET_CODE Receive (void *const data, const uint maxlen)
const OPENCITY_NET_CODE ReceiveMessage (NetMessage &rMsg)
const OPENCITY_NET_CODE Receive (void *const data, const uint maxlen, const uint cid)

Private Attributes

OPENCITY_NET_CODE networkingCode
bool boolNetworkInitialized
std::vector< NetnodevClient
SDLNet_SocketSet pSocketSet
 The server puts all its client sockets into this set.
TCPsocket pServerSocket


Detailed Description

Offer the OpenCity gamers a possibility to share their experience with the others through the networks.

Definition at line 125 of file networking.h.


Member Function Documentation

const OPENCITY_NET_CODE Networking::Accept uint &  rid  ) 
 

SERVER: Accept the connection request from a machine.

Parameters:
rid The index of the newly accepted client (>=0)

Definition at line 138 of file networking.cpp.

References NetMessage::cmd, Netnode::ip, SendMessage(), and Netnode::socket.

Referenced by ProcessServerData().

const OPENCITY_NET_CODE Networking::Close ClientIter  i  ) 
 

SERVER: close the connection to a client CLIENT: this command is not available

Returns:
the following enumerations:

Definition at line 379 of file networking.cpp.

const OPENCITY_NET_CODE Networking::Close  ) 
 

SERVER: close the connection to a super server CLIENT: close the connection to a server

Returns:
the following enumerations:

Definition at line 360 of file networking.cpp.

References NetMessage::cmd, pServerSocket, and SendMessage().

Referenced by ProcessServerData().

const string Networking::GetClientHost const uint  index  ) 
 

Returns:
the host (resolved IP) of the specified client

Definition at line 58 of file networking.cpp.

const uint Networking::GetClientMax  ) 
 

Returns:
the maximum number of the connections that the server can handle. If the queried machine is running OpenCity as a client application, the returned value is undefined.

Definition at line 76 of file networking.cpp.

const uint Networking::GetClientNum  ) 
 

Returns:
the current number of active connections

Definition at line 68 of file networking.cpp.

const uint Networking::GetPingTimeout  ) 
 

Returns:
the maximum ping time in millisecond.

Definition at line 92 of file networking.cpp.

const string Networking::GetProtocol  ) 
 

Returns:
the string which describes the latest OpenCity networking protocol that the machine can understand. The returned string is in the form: x.y.z like 0.0.1

Definition at line 130 of file networking.cpp.

const string Networking::GetServerHost const uint  index  ) 
 

Returns:
the host (resolved IP) of the specified server

Definition at line 111 of file networking.cpp.

const uint Networking::GetServerNum  ) 
 

Returns:
the number of servers that the machine knows

Definition at line 100 of file networking.cpp.

const string Networking::GetVersion  ) 
 

Returns:
the string which describes the OpenCity version of the remote machine. Example: 0.0.2beta

Definition at line 122 of file networking.cpp.

const OPENCITY_NET_CODE Networking::Open const string  serverHost,
const OC_SUINT  port = OC_NET_SERVER_PORT
 

SERVER: try to connect to a another server CLIENT: try to connect to a server

Returns:
the following enumerations:

Definition at line 309 of file networking.cpp.

References NetMessage::cmd, and pServerSocket.

const OPENCITY_NET_CODE Networking::ProcessServerData  ) 
 

SERVER: check the avaibility of data sent by clients and process them. This is a non-blocking call

Returns:
Always return OC_NET_OK

Definition at line 253 of file networking.cpp.

References Accept(), Close(), and NetMessage::cmd.

const OPENCITY_NET_CODE Networking::Receive void *const   data,
const uint  maxlen,
const uint  cid
 

SERVER: read the data sent by a super server specified by its index CLIENT: this method is _not_ available to a client

Returns:
Error code

Definition at line 520 of file networking.cpp.

const OPENCITY_NET_CODE Networking::Receive void *const   data,
const uint  maxlen
 

SERVER: read the data sent by a super server CLIENT: read the data sent by the server

Returns:
the following enumerations:

Definition at line 480 of file networking.cpp.

Referenced by ReceiveMessage().

const OPENCITY_NET_CODE Networking::ReceiveMessage NetMessage rMsg  ) 
 

Wait for the specified incoming command. SERVER: wait for the command sent by a super server CLIENT: wait for the command sent by a server

Note:
Blocking method

Definition at line 506 of file networking.cpp.

References Receive().

const OPENCITY_NET_CODE Networking::Reject const uint  id  ) 
 

SERVER: Reject the connection request from a machine.

Definition at line 188 of file networking.cpp.

const OPENCITY_NET_CODE Networking::Send const void *const   data,
const uint  len,
const uint  cid
 

SERVER: send the data to a client CLIENT: this method is _not_ available to a client machine

Returns:
the following enumerations:

Definition at line 428 of file networking.cpp.

const OPENCITY_NET_CODE Networking::Send const void *const   data,
const uint  len
 

SERVER: send the data to a super server CLIENT: send the data to the server

Returns:
the following enumerations:

Definition at line 402 of file networking.cpp.

Referenced by SendMessage().

const OPENCITY_NET_CODE Networking::SendMessage NetMessage rMsg,
const uint  cid
 

SERVER: send the message to a super server CLIENT: this method is _not_ available to a client host

Definition at line 468 of file networking.cpp.

References NetMessage::dataLength, and Send().

const OPENCITY_NET_CODE Networking::SendMessage NetMessage rMsg  ) 
 

SERVER: send the message to a super server CLIENT: send the message to a server

Definition at line 454 of file networking.cpp.

References NetMessage::dataLength, and Send().

Referenced by Accept(), and Close().

const OPENCITY_NET_CODE Networking::StartServer const OC_SUINT  port = OC_NET_SERVER_PORT  ) 
 

SERVER: Create a new socket and begin to listen for incoming connection requests. Return the following enumerations: OC_SERVER_READY OC_SERVER_STARTED

Definition at line 198 of file networking.cpp.

References pServerSocket, and pSocketSet.

const OPENCITY_NET_CODE Networking::StopServer  ) 
 

SERVER: close the server socket and free all server's ressources.

Returns:
the following enumerations: OC_SERVER_STOPED

Definition at line 234 of file networking.cpp.

References pServerSocket, and pSocketSet.


Member Data Documentation

TCPsocket Networking::pServerSocket [private]
 

The server listens on this socket The client use this socket to communicate with the server

Definition at line 374 of file networking.h.

Referenced by Close(), Open(), StartServer(), and StopServer().


The documentation for this class was generated from the following files:
Generated on Sat Nov 11 10:21:11 2006 for OpenCity by  doxygen 1.4.2