- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# LightweightDatabaseServer Class Reference
[LightweightDatabase]

A simple flat database included with RakNet, useful for a server browser or a lobby server. A flat database interface. Adds the ability to track IPs of row updaters and passwords for table read and write operations, Best used for data in which queries which do not need to be updated in real-time. More...

`#include <LightweightDatabaseServer.h>`

Inheritance diagram for LightweightDatabaseServer:

List of all members.

## Public Member Functions
| LightweightDatabaseServer ()
| Constructor.
| ~LightweightDatabaseServer ()
| Destructor.
DataStructures::Table * | GetTable (char *tableName)
DataStructures::Table * | AddTable (char *tableName, bool allowRemoteQuery, bool allowRemoteUpdate, bool allowRemoteRemove, char queryPassword[_SIMPLE_DATABASE_PASSWORD_LENGTH], char updatePassword[_SIMPLE_DATABASE_PASSWORD_LENGTH], char removePassword[_SIMPLE_DATABASE_PASSWORD_LENGTH], bool oneRowPerSystemId, bool onlyUpdateOwnRows, bool removeRowOnPingFailure, bool removeRowOnDisconnect, bool autogenerateRowIDs)
bool | RemoveTable (char *tableName)
void | Clear (void)
| Clears all memory.
unsigned | GetAndIncrementRowID (char *tableName)
DataStructures::Page< unsigned, DataStructures::Table::Row *, _TABLE_BPLUS_TREE_ORDER > * | GetTableRows (char *tableName)
virtual void | OnAttach (RakPeerInterface *peer)
virtual void | Update (RakPeerInterface *peer)
virtual PluginReceiveResult | OnReceive (RakPeerInterface *peer, Packet *packet)
virtual void | OnDisconnect (RakPeerInterface *peer)
virtual void | OnCloseConnection (RakPeerInterface *peer, PlayerID playerId)
## Static Public Member Functions
static int | DatabaseTableComp (char *const &key1, char *const &key2)
## Protected Member Functions
void | OnQueryRequest (RakPeerInterface *peer, Packet *packet)
void | OnUpdateRow (RakPeerInterface *peer, Packet *packet)
void | OnRemoveRow (RakPeerInterface *peer, Packet *packet)
void | OnPong (RakPeerInterface *peer, Packet *packet)
DatabaseTable * | DeserializeClientHeader (RakNet::BitStream *inBitstream, RakPeerInterface *peer, Packet *packet, int mode)
DataStructures::Table::Row * | GetRowFromIP (DatabaseTable *databaseTable, PlayerID playerId, unsigned *rowId)
bool | RowHasIP (DataStructures::Table::Row *row, PlayerID playerId, unsigned systemIdColumnIndex)
DataStructures::Table::Row * | AddRow (LightweightDatabaseServer::DatabaseTable *databaseTable, PlayerID playerId, bool hasRowId, unsigned rowId)
void | RemoveRowsFromIP (PlayerID playerId)
## Protected Attributes
DataStructures::Map< char *, LightweightDatabaseServer::DatabaseTable *, LightweightDatabaseServer::DatabaseTableComp > | database
## Classes
struct | DatabaseTable

## Detailed Description

A simple flat database included with RakNet, useful for a server browser or a lobby server. A flat database interface. Adds the ability to track IPs of row updaters and passwords for table read and write operations, Best used for data in which queries which do not need to be updated in real-time.

## Member Function Documentation

DataStructures::Table * LightweightDatabaseServer::AddTable | ( | char * | tableName,
|  | bool | allowRemoteQuery,
|  | bool | allowRemoteUpdate,
|  | bool | allowRemoteRemove,
|  | char | queryPassword[_SIMPLE_DATABASE_PASSWORD_LENGTH],
|  | char | updatePassword[_SIMPLE_DATABASE_PASSWORD_LENGTH],
|  | char | removePassword[_SIMPLE_DATABASE_PASSWORD_LENGTH],
|  | bool | oneRowPerSystemId,
|  | bool | onlyUpdateOwnRows,
|  | bool | removeRowOnPingFailure,
|  | bool | removeRowOnDisconnect,
|  | bool | autogenerateRowIDs
| ) |

  | Adds a new table It is valid to read and write to the returned pointer. Parameters:
  `[in]` | tableName | Name of the new table to create. Remote systems will refer to this table by this name.
  `[in]` | allowRemoteQuery | true to allow remote systems to query the table. false to not allow this.
  `[in]` | allowRemoteUpdate | true to allow remote systems to update rows in the table. false to not allow this.
  `[in]` | allowRemoteRemove | true to allow remote systems to remove rows from the table. false to not allow this.
  `[in]` | queryPassword | The password required to query the table. Pass an empty string for no password.
  `[in]` | updatePassword | The password required to update rows in the table. Pass an empty string for no password.
  `[in]` | removePassword | The password required to remove rows from the table. Pass an empty string for no password.
  `[in]` | oneRowPerSystemId | Only used if allowRemoteUpdate==true. This limits remote systems to one row.
  `[in]` | onlyUpdateOwnRows | Only used if allowRemoteUpdate==true. This limits remote systems to only updating rows they created.
  `[in]` | removeRowOnPingFailure | Only used if allowRemoteUpdate==true and removeRowOnDisconnect==false. If true, this will periodically ping disconnected systems and remove rows created by that system if that system does not respond to pings.
  `[in]` | removeRowOnDisconnect | Only used if allowRemoteUpdate==true. This removes rows created by a system when that system disconnects.
  `[in]` | autogenerateRowIDs | true to automatically generate row IDs. Rows are stored in order by row ID. If false, the clients must specify a unique row ID when adding rows. If they specify a row that already exists the addition is ignored.
Returns: The newly created table, or 0 on failure.

DataStructures::Table * LightweightDatabaseServer::GetTable | ( | char * | tableName | ) |

  | Returns a table by name. It is valid to read and write to the returned pointer. Parameters:
  `[in]` | tableName | The name of the table that was passed to AddTable
Returns: The requested table, or 0 if tableName cannot be found.

DataStructures::Page< unsigned, DataStructures::Table::Row *, _TABLE_BPLUS_TREE_ORDER > * LightweightDatabaseServer::GetTableRows | ( | char * | tableName | ) |

  | Returns a linked list of ordered lists containing the rows of a table, by name. The returned structure is internal to the BPlus tree. See DS_BPlusTree This is a convenience accessor, as you can also get this from the table returned from GetTable() Parameters:
  `[in]` | tableName | The name of the table that was passed to AddTable
Returns: The requested rows, or 0 if tableName cannot be found.

void LightweightDatabaseServer::OnAttach | ( | RakPeerInterface * | peer | ) | `[virtual]`

  | Called when the interface is attached Parameters:
  `[in]` | peer | the instance of RakPeer that is calling Receive
Reimplemented from PluginInterface.

void LightweightDatabaseServer::OnCloseConnection | ( | RakPeerInterface * | peer,
|  | PlayerID | playerId
| ) | `[virtual]`

  | Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system Parameters:
  `[in]` | peer | the instance of RakPeer that is calling Receive
  `[in]` | playerId | The system whose connection was closed
Reimplemented from PluginInterface.

void LightweightDatabaseServer::OnDisconnect | ( | RakPeerInterface * | peer | ) | `[virtual]`

  | Called when RakPeer is shutdown Parameters:
  `[in]` | peer | the instance of RakPeer that is calling Receive
Reimplemented from PluginInterface.

PluginReceiveResult LightweightDatabaseServer::OnReceive | ( | RakPeerInterface * | peer,
|  | Packet * | packet
| ) | `[virtual]`

  | OnReceive is called for every packet. Parameters:
  `[in]` | peer | the instance of RakPeer that is calling Receive
  `[in]` | packet | the packet that is being returned to the user
Returns: True to allow the game and other plugins to get this message, false to absorb it Reimplemented from PluginInterface.

bool LightweightDatabaseServer::RemoveTable | ( | char * | tableName | ) |

  | Removes a table by name. Parameters:
  `[in]` | tableName | The name of the table that was passed to AddTable
Returns: true on success, false on failure.

void LightweightDatabaseServer::Update | ( | RakPeerInterface * | peer | ) | `[virtual]`

  | Update is called every time a packet is checked for . Parameters:
  `[in]` | peer | - the instance of RakPeer that is calling Receive
Reimplemented from PluginInterface.

The documentation for this class was generated from the following files:

- C:/RakNet 2.518/Include/LightweightDatabaseServer.h
- C:/RakNet 2.518/Source/LightweightDatabaseServer.cpp