View lcov test coverage results on http://www.gnu.org/software/liquidwar6/coverage/src/lib/nod/index.html.
dyn_info: the dyn info struct to free
Frees a dyn info object, to be used after a call to
lw6nod_info_dup_dyn
for instance.Return value: none
program: the program (normally it's liquidwar6)
version: the version
codename: the codename
stamp: the stamp
id: the node id
url: the node public url
title: the node title
description: the node description
password: the node password
bench: the node bench
open_relay: open relay or not
uptime: uptime in seconds
idle_screenshot_size: the size (bytes) of the image to display when game is idle
idle_screenshot_data: the data (jpeg) of the image to display when game is idle
Creates a node info object. The arguments correspond to the immutable node attributes, other properties such as how many players are connected or set in other functions like
lw6nod_info_update
which can be called later.Return value: newly allocated object, NULL on error.
info: the node info to free
Frees a node info object.
Return value: none
info: the node info to lock
Locks a node info object, this is usefull for some members, typically list of servers, can be accessed by separated threads, one reading, many writing, and these objects (chained lists) certainly do not want to be modified while being read.
Return value: 1 if ok, 0 if not.
info: the node info to unlock
Unlocks a node info object, this is the compation of the
lw6nod_info_lock
function.Return value: 1 if ok, 0 if not.
info: the node info to modify
Clears a node info object and sets all its variable attributes to NULL/default values. This is what we want when the node is idle, not playing.
Return value: none.
info: the node info to update
community_id: the id of the community the node belongs to
round: the current round (can have an offset with real round number)
level: the name of the current level (map)
required_bench: the bench required to connect
nb_colors: number of colors playing
max_nb_colors: max number of colors allowed
nb_cursors: number of cursors playing
max_nb_cursors: max number of cursors allowed
nb_nodes: number of nodes playing
max_nb_nodes: max number of nodes allowed
game_screenshot_size: size of screenshot (bytes)
game_screenshot_data: screenshot data (byte buffer, contains JPEG)
Set a node info object variable attributes. Call this whenever the node has changed some parameter. Not too often for it's not needed and some operations such as modying the screenshot, can be time consuming.
Return value: 1 if OK, 0 if error.
info: the node info containing the dyn info to duplicate
Extracts the dynamic part of an info struct and duplicates it, this is to avoid protection fault error when concurrent threads access this info.
Return value: newly allocated object, must be freed.
Creates a new hash, to be used as a discovered nodes list. Using this function has the advantage of setting the hash options to their defaults. We use a hash to avoid having uselessly long lists containing always the same node due to multiple detections.
Return value: an empty hash
info: the node info to update
public_url: the address of the discovered node
Registers a new server, and queues it as something that should be checked later because it's interesting. We can't insert in the database all the servers we suspect to exist so network threads should use this, then main thread will process discovered servers afterwards. This is also a good way to avoid trivial DOS attacks.
Return value: 1 if OK, O if error.
info: the node info to query
Returns a list of all discovered nodes (their public URL) and empties the current queue as well.
Return value: a list of dynamically allocated strings.
Creates a new list, to be filled with nodes and typically passed to
lw6nod_info_set_verified_nodes
. Using this function has the advantage of setting the listh options to their defaults.Return value: an empty list
info: the node info to modify
list: the list of verified nodes, will be freed by this function
Sets the list of verified nodes, that is, the list of nodes we are sure to exist, this is typically the list we will display later on a web page. We can't directly display any discovered node, one needs to filter them through main thread. Something very important about this function is that
list
will be freed by function, that is, if you call this, then you can (you should) forget your object, it will disappear any time soon.Return value: 1 if OK, 0 on error.
info: the node info concerned
func: the function to apply
func_data: arbitrary pointer holding data to pass to function
Calls
lw6sys_hash_map
withfunc
on every member of the list of verified nodes. The reason there's a function for this is that it is very important that list object is locked when doing this. This function does perform a lock/unlock so it is safe.Return value: none.