#include <RakServer.h>
Inheritance diagram for RakServer:
Public Member Functions | |
RakServer () | |
Constructor. | |
virtual | ~RakServer () |
Destructor. | |
bool | Start (unsigned short AllowedPlayers, unsigned int depreciated, int threadSleepTimer, unsigned short port, const char *forceHostAddress=0) |
void | InitializeSecurity (const char *privateKeyE, const char *privateKeyN) |
void | DisableSecurity (void) |
void | SetPassword (const char *_password) |
bool | HasPassword (void) |
Returns if non-zero was passed to SetPassword(). | |
void | Disconnect (unsigned int blockDuration, unsigned char orderingChannel=0) |
bool | Send (const char *data, const int length, PacketPriority priority, PacketReliability reliability, char orderingChannel, PlayerID playerId, bool broadcast) |
bool | Send (RakNet::BitStream *bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, PlayerID playerId, bool broadcast) |
Packet * | Receive (void) |
void | Kick (const PlayerID playerId) |
void | DeallocatePacket (Packet *packet) |
void | SetAllowedPlayers (unsigned short AllowedPlayers) |
unsigned short | GetAllowedPlayers (void) const |
unsigned short | GetConnectedPlayers (void) |
void | GetPlayerIPFromID (const PlayerID playerId, char returnValue[22], unsigned short *port) |
void | PingPlayer (const PlayerID playerId) |
int | GetAveragePing (const PlayerID playerId) |
int | GetLastPing (const PlayerID playerId) |
int | GetLowestPing (const PlayerID playerId) |
void | StartOccasionalPing (void) |
void | StopOccasionalPing (void) |
Stop pinging players every so often. Players are pinged by default. In games where you don't care about ping you can call this to save the bandwidthThis will work anytime. | |
bool | IsActive (void) const |
Returns true if the server is currently active. | |
unsigned int | GetSynchronizedRandomInteger (void) const |
void | StartSynchronizedRandomInteger (void) |
Start or restart the synchronized random integer. This is on by default. Call StopSynchronizedRandomIntegerto stop it keeping the number in synch. | |
void | StopSynchronizedRandomInteger (void) |
Stop the synchronized random integer. Call StartSynchronizedRandomInteger to start it again. | |
bool | GenerateCompressionLayer (unsigned int inputFrequencyTable[256], bool inputLayer) |
bool | DeleteCompressionLayer (bool inputLayer) |
void | RegisterAsRemoteProcedureCall (char *uniqueID, void(*functionPointer)(RPCParameters *rpcParms)) |
void | RegisterClassMemberRPC (char *uniqueID, void *functionPointer) |
void | UnregisterAsRemoteProcedureCall (char *uniqueID) |
bool | RPC (char *uniqueID, const char *data, unsigned int bitLength, PacketPriority priority, PacketReliability reliability, char orderingChannel, PlayerID playerId, bool broadcast, bool shiftTimestamp, NetworkID networkID, RakNet::BitStream *replyFromTarget) |
bool | RPC (char *uniqueID, RakNet::BitStream *bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, PlayerID playerId, bool broadcast, bool shiftTimestamp, NetworkID networkID, RakNet::BitStream *replyFromTarget) |
void | SetTrackFrequencyTable (bool b) |
bool | GetSendFrequencyTable (unsigned int outputFrequencyTable[256]) |
float | GetCompressionRatio (void) const |
float | GetDecompressionRatio (void) const |
void | AttachPlugin (PluginInterface *messageHandler) |
void | DetachPlugin (PluginInterface *messageHandler) |
RakNet::BitStream * | GetStaticServerData (void) |
void | SetStaticServerData (const char *data, const int length) |
void | SetRelayStaticClientData (bool b) |
void | SendStaticServerDataToClient (const PlayerID playerId) |
void | SetOfflinePingResponse (const char *data, const unsigned int length) |
RakNet::BitStream * | GetStaticClientData (const PlayerID playerId) |
void | SetStaticClientData (const PlayerID playerId, const char *data, const int length) |
void | ChangeStaticClientData (const PlayerID playerChangedId, PlayerID playerToSendToId) |
unsigned int | GetNumberOfAddresses (void) |
const char * | GetLocalIP (unsigned int index) |
PlayerID | GetInternalID (void) const |
void | PushBackPacket (Packet *packet, bool pushAtHead) |
void | SetRouterInterface (RouterInterface *routerInterface) |
For internal use only.
| |
void | RemoveRouterInterface (RouterInterface *routerInterface) |
For internal use only.
| |
int | GetIndexFromPlayerID (const PlayerID playerId) |
PlayerID | GetPlayerIDFromIndex (int index) |
void | AddToBanList (const char *IP) |
void | RemoveFromBanList (const char *IP) |
void | ClearBanList (void) |
Allows all previously banned IPs to connect. | |
bool | IsBanned (const char *IP) |
bool | IsActivePlayerID (const PlayerID playerId) |
void | SetTimeoutTime (RakNetTime timeMS, const PlayerID target) |
bool | SetMTUSize (int size) |
int | GetMTUSize (void) const |
void | AdvertiseSystem (const char *host, unsigned short remotePort, const char *data, int dataLength) |
RakNetStatisticsStruct *const | GetStatistics (const PlayerID playerId) |
void | ApplyNetworkSimulator (double maxSendBPS, unsigned short minExtraPing, unsigned short extraPingVariance) |
virtual bool | IsNetworkSimulatorActive (void) |
Private Attributes | |
unsigned int | seed |
unsigned int | nextSeed |
RakNetTime | broadcastPingsTime |
RakNetTime | nextSeedUpdate |
bool | synchronizedRandomInteger |
bool | relayStaticClientData |
This is a user-interface class to act as a game server. All it does is implement some functionality on top of RakPeer. See the individual functions for what the class can do.
|
Bans an IP from connecting. Banned IPs persist between connections. param[in] IP Dotted IP address. Can use * as a wildcard, such as 128.0.0.* will banAll IP addresses starting with 128.0.0 Implements RakServerInterface. |
|
Sends a one byte message ID_ADVERTISE_SYSTEM to the remote unconnected system. This will tell the remote system our external IP outside the LAN along with some user data..
Reimplemented from RakPeer. |
|
Adds simulated ping and packet loss to the outgoing data flow. To simulate bi-directional ping and packet loss, you should call this on both the sender and the recipient, with half the total ping and maxSendBPS value on each. You can exclude network simulator code with the _RELEASE define to decrease code size
Reimplemented from RakPeer. |
|
Attatches a Plugin interface to run code automatically on message receipt in the Receive call
Reimplemented from RakPeer. |
|
This function is used to update the information on connected clients when the server effects a change of static client data. Note that a client that gets this new information for himself will update the data for his playerID but not his local data (which is the user's copy) i.e. player 5 would have the data returned by GetStaticClientData(5) changed but his local information returned byGetStaticClientData(UNASSIGNED_PLAYER_ID) would remain the same as it was previously.
Implements RakServerInterface. |
|
Call this to deallocate a packet returned by Receive when you are done handling it.
Reimplemented from RakPeer. |
|
Delete the output or input layer as specified. This is not necessary to call and is only valuable for freeing memory.
Reimplemented from RakPeer. |
|
Detaches a Plugin interface to run code automatically on message receipt
Reimplemented from RakPeer. |
|
Disables all security.
Reimplemented from RakPeer. |
|
Stops the server, stops synchronized data, and resets all internal data. This will drop all players currently connected, howeversince the server is stopped packet reliability is not enforced so the Kick network message may not actuallyarrive. Those players will disconnect due to timeout. If you want to end the server more gracefully, youcan manually Kick each player first. Does nothing if the server is not running to begin with
Reimplemented from RakPeer. |
|
This is an optional function to generate the compression layer based on the input frequency table. If you want to use it you should call this twice - once with inputLayer as true and once as false. The frequency table passed here with inputLayer=true should match the frequency table on the recipient with inputLayer=false. Likewise, the frequency table passed here with inputLayer=false should match the frequency table on the recipient with inputLayer=true. Calling this function when there is an existing layer will overwrite the old layer.
Reimplemented from RakPeer. |
|
Return how many players are allowed to connect. This value was set either from Start or from SetAllowedPlayers.
Implements RakServerInterface. |
|
Returns the average of all ping times read for the specific player or -1 if none read yet
Reimplemented from RakPeer. |
|
Returns the compression ratio. A low compression ratio is good. Compression is for outgoing data
Reimplemented from RakPeer. |
|
Return how many players are currently connected to the server.
Implements RakServerInterface. |
|
Returns the decompression ratio. A high decompression ratio is good. Decompression is for incoming data
Reimplemented from RakPeer. |
|
Given a playerID, returns an index from 0 to the maximum number of players allowed - 1.
Reimplemented from RakPeer. |
|
Return the unique address identifier that represents you on the the network and is based on your local IP / port.
Reimplemented from RakPeer. |
|
Returns the last ping time read for the specific player or -1 if none read yet
Implements RakServerInterface. |
|
Call this function where 0 <= index < x where x is the value returned by GetNumberOfAddresses() Returns a static string filled with the server IP of the specified index. Strings returned in no particular order. You'll have to check every index see which string you want.
Reimplemented from RakPeer. |
|
Returns the lowest ping time read or -1 if none read yet
Implements RakServerInterface. |
|
Returns the current MTU size
Reimplemented from RakPeer. |
|
Internally store the IP address(es) for the server and return how many it has. This can easily be more than one, for example a system on both a LAN and with a net connection. The server does not have to be active for this to work Reimplemented from RakPeer. |
|
This function is only useful for looping through all players. Given an index, will return a PlayerID.
Reimplemented from RakPeer. |
|
Returns a static string pointer containing the IP of the specified connected player. Also returns the client port. This changes between calls so be sure to copy what is returned if you need to retain it. Useful for creating and maintaining ban lists.
Implements RakServerInterface. |
|
Returns the frequency of outgoing bytes into outputFrequencyTable. This is required to get a frequency table, which is used in GenerateCompressionLayer() The purpose is to save to file as either a master frequency table from a sample game session.
Implements RakServerInterface. |
|
Returns a pointer to an attached client's static data specified by the playerId. Returns 0 if no such player is connected.
Implements RakServerInterface. |
|
The server internally maintains a data struct that is automatically sent to clients when they connect. This is useful to contain data such as the server name or message of the day. Access that struct with thisfunction.
Implements RakServerInterface. |
|
Returns a structure containing a large set of network statistics for the specified system. You can map this data to a string using the C style StatisticsToString() function
Reimplemented from RakPeer. |
|
Returns a number automatically synchronized between the server and client which randomly changes every 9 seconds. The time it changes is accurate to within a few ms and is best used to seed random number generators that you want to usually return the same output on all systems. Keep in mind thisisn't perfectly accurate as there is always a very small chance the numbers will by out of synch. You should should confine its use to visual effects or functionality that has a backup method to maintain synchronization. If you don't need this functionality and want to save the bandwidth callStopSynchronizedRandomInteger after starting the server
Implements RakServerInterface. |
|
Must be called while offlineSecures connections though a combination of SHA1, AES128, SYN Cookies, and RSA to preventconnection spoofing, replay attacks, data eavesdropping, packet tampering, and MitM attacks.There is a significant amount of processing and a slight amount of bandwidthoverhead for this feature.If you accept connections, you must call this or else secure connections will not be enabledfor incoming connections. If the private keys are 0, then a new key will be generated when this function is called
Implements RakServerInterface. |
|
Returns true if that player ID is currently active
Implements RakServerInterface. |
|
Returns true or false indicating if a particular IP is banned.
Reimplemented from RakPeer. |
|
Returns if you previously called ApplyNetworkSimulator
Reimplemented from RakPeer. |
|
Kick out the specified player.
Implements RakServerInterface. |
|
Send a ping request to the specified player
Implements RakServerInterface. |
|
Put a packet back at the end of the receive queue in case you don't want to deal with it immediately.
Reimplemented from RakPeer. |
|
Gets a packet from the incoming packet queue. Use DeallocatePacket() to deallocate the packet after you are done with it. User-thread functions, such as RPC calls and the plugin function PluginInterface::Update occur here.
Reimplemented from RakPeer. |
|
Allows a previously banned IP to connect. param[in] Dotted IP address. Can use * as a wildcard, such as 128.0.0.* will banAll IP addresses starting with 128.0.0 Reimplemented from RakPeer. |
|
/pre The server must be active. Send the data stream of length length to whichever playerId you specify.
Reimplemented from RakPeer. |
|
/pre The server must be active. Send the data stream of length length to whichever playerId you specify.
Reimplemented from RakPeer. |
|
Send the static server data to the specified player. Pass UNASSIGNED_PLAYER_ID to broadcast to all players. The only time you need to call this function is to update clients that are already connected when you change the static server data by calling GetStaticServerData() and directly modifying the object pointed to. Obviously if theconnected clients don't need to know the new data you don't need to update them, so it's up to you.
Implements RakServerInterface. |
|
Set how many players are allowed on the server. If more players are currently connected then are allowed then no more players will be allowed to join until the number of players is less than the number of allowed players.
Implements RakServerInterface. |
|
Set the MTU per datagram. It's important to set this correctly - otherwise packets will be needlessly split, decreasing performance and throughput. Maximum allowed size is MAXIMUM_MTU_SIZE. Too high of a value will cause packets not to arrive at worst and be fragmented at best. Too low of a value will split packets unnecessarily. sa MTUSize.h
Reimplemented from RakPeer. |
|
Sets the data to send along with a LAN server discovery or offline ping reply. length should be under 400 bytes, as a security measure against flood attacks
Reimplemented from RakPeer. |
|
Set the password clients have to use to connect to this server. The password persists between connections. Pass 0 for no password. You can call this anytime
Implements RakServerInterface. |
|
This sets to true or false whether we want to support relaying of static client data to other connected clients. If set to false it saves some bandwdith, however other clients won't know the static client data and attempting to read that data will return garbage. Default is false. This only works for up to 32 players. Games supporting more than 32 players will have this shut off automatically upon server start and must have it forced back on with this function if you do indeed want it.
Implements RakServerInterface. |
|
Set the stait client data for a particular player
Implements RakServerInterface. |
|
The server internally maintains a data struct that is automatically sent to clients when they connect. This function will set that data.
Implements RakServerInterface. |
|
Set the time, in MS, to use before considering ourselves disconnected after not being able to deliver a reliable packet Default time is 10,000 or 10 seconds in release and 30,000 or 30 seconds in debug.
Reimplemented from RakPeer. |
|
Enables or disables frequency table tracking. This is required to get a frequency table, which is used in GenerateCompressionLayer() This value persists between connect calls and defaults to false (no frequency tracking)
Implements RakServerInterface. |
|
Call this to initiate the server with the number of players you want to be allowed connected at once
Implements RakServerInterface. |
|
Ping all players every so often. This is on by default. In games where you don't care about ping you can callStopOccasionalPing to save the bandwidth. This can be called anytime. Implements RakServerInterface. |