Find information about the architecture and examples of BCI2000 Hyperscanning here: BCI2000 Hyperscanning
Backend implementation of a client connection.
int socket
: File descriptor of the client connection
int timeout
: no longer in use
std::string ip
: IPv4 Address of the client
int port
: Port of the client
Updates the clients internal state machine (aka server-side-client state machine), Client::states
. Changes are tracked in Client::stateChanges
. Blocks for 2ms to check if the client wrote to the socket before moving on. Also checks if the client disconnected.\
Returns:
false if client disconnected. true otherwise.
Updates the client with new states. Sends otherStates.message()
, preceded by the size of the message.
StateMachine otherStates
: State machine with states to send to client. All of the states in the state machine will be sent.
returns:
true if states were sent successfully. false otherwise.
returns ture if Client* o
has the same IP Address and Port as it
File descriptor of client connection
IP Address of client connected
Port of client connected
ClientNumber id of the connected client
Server-side-client state machine
Tracker for Client::states
Object that connects Client
s and runs the game loop for them
Port port
: Port object that this games clients will connect to
std::string params
: std::string
containing BCI2000 parameter file to be sent to each client
Connects a client to the game. Calls Game::ConnectClient()
and Game::ValidateStates()
with given client and adds them to the list of connected clients.
Client* client
: Client object to connect to the game
returns:
true unless client does not exist.
Sends greeting message with client number id and BCI2000 parameters defined in Client::params
.
Client* client
: Client to connect to the game
Waits for client to send shared states list. Validates that this client has the same shared states as the other client(s) or saves this clients shared states as the standard if it is the first one.
Client* client
: Client to validate
Adds a client to the list of clients connected to the game
Client* client
: Client to add
Executes Game::Update
untill a client disconnects
returns:
Game::masterStates
Executes one iterance of the server loop. Reads clients, reconciles, and sends client updates.
returns:
true unless client disconnected
Reads game state updates from the clients
returns:
false if client disconnected, true otherwise
Reconciles client game state updates
Sends game state updates to clients
returns:
false if client disconnected, true otherwise
(unused) Port object from which this game's clients are connecting
std::string
containing BCI2000 parameters to be sent to each client during Game::ConnectClient
list of shared states used to validate clients when they are connecting
list of connected clients
Master state machine of the game
One BCI2000 parameter line
Param::Param( std::string line, std::string name, std::string value, int length = 1, int width = 1 )
std::string line
: Everything after BCI2000 parameter "="
std::string name
: Name of the BCI2000 parameter
std::string value
: value of the BCI2000 parameter
int length
: length of the BCI2000 parameter if list or matrix (default 1)
int width
: width of the BCI2000 parameter if matrix (default 1)
Everything after BCI2000 parameter "="
Name of the BCI2000 parameter
value of the BCI2000 parameter
length of the BCI2000 parameter if list or matrix (default 1)
width of the BCI2000 parameter if matrix (default 1)
Object representation of a BCI2000 parameter file
Parameter object from file
std::string file
: BCI2000 parameter file to read
Blank parameter object
Get Param
object for a specific parameter
Arguments:
std::string name
: Name of the parameter to get
Returns:
Pointer to a Param
object containing the parameter information
Adds the specified parameter to the represented parameter file
Arguments:
std::string param
: Full parameter line to add
void Params::AddParam( std::string location, std::string type, std::string name, std::string value, std::string defaultValue = "%", std::string lowRange = "%", std::string highRange = "%", std::string comment = "default comment", std::string width = "", std::string height = "" )
Adds the specified parameter to the represented parameter file
Arguments:
std::string location
: Location of parameter in BCI2000 config window, e.g. Application:Sequence or Source
std::string type
: Type of parameter, e.g. int, intlist, or matrix
std::string name
: Name of the parameter
std::string value
: Value of the parameter
std::string defaultValue
: default value of the parameter (defaults to "%", which is no defualt value)
std::string lowRange
: low range of the parameter value (defaults to "%", which is no low range)
std::string highRange
: high range of the parameter value (defaults to "%", which is no high range)
std::string comment
: comment describing the parameter (defaults to "default comment")
std::string width
: Width (if list or matrix) of the dataset. Can be a number or "{" or "[" contained list
std::string height
: Height (if matrix) of the dataset. Can be a number or "{" or "[" contained list
Adds the specified parameter to the represetnted parameter file from a parameter object
Arguments:
Param param
: parameter object to add
Object that manages socket connections and a port opening
Constructs a Port object at a specified port
Arguments:
int port
: Number of the port to open the sockets at
int to
: (NOTHING)
Blocks until client connects
Returns:
Pointer to the Client
object for the client that connected
Checks if a client is currently attempting to connect
Returns:
Pointer to the Client
object fo the client that connected, if a client was waiting, otherwise nullptr
State machine object that stores states with names and values
Creates new blank state machine
Gets the value of a state from the state machine
Arguments:
std::string name
: Name of the state to retrieve
Retruns:
const char*
with the value of the state
Sets a state to a value. Creates a new state if one does not exist.
Arguments:
std::string name
: Name of the state to create or change
std::string value
: Value to change or create the state to
Returns:
false
if the state was set to a new value, otherwise true
Interpret a client message, and update states accordingly. Tracks changes to any states.
Arguments:
const char* buffer
: Buffer containing message to interpret
StateMachine* tracker
: Pointer to the state machine that changes will be recorded in.
Gets a message in the client-server data exchange format containing all of the states within the state machine
Returns:
std::string
containing the message