BeamServer .NET Client

The BeamServer .NET Client API is based on the class BSClient and the interface BeamClientListener, both within the BeamClient namespace. You can implement the interface in any of your classes and then attach them to an object of class BSClient by calling its addListener method.

BSClient class

ConnectToServer(String ip, int port)

Connects to the BeamServer server associated to the IP address and the specified port.

If successful an OnConnect event is dispatched.

String ip : Server IP address.
int port : Server port number.

CloseConnection()

Closes the connection with the server.

When the connection is closed an OnDisconnect event is dispatched.

int GetId()

Output: Returns the unique ID of the node that represents our connection inside the server.

LoginToServer(String user, String pass)

Sends a login request to the server with the user name and password specified. It is esential to do this before any other operation on the server.

Once the request has been procesed by the server an OnLogin event is received, indicating the success or failure of the proccess.

String user : User name.
String pass : Password.

JoinNode(int nodeId, String user, String pass)

This function makes our connection node join to the node list of the specified node.

int nodeId : Unique ID of the node we want to join.
String user : User name.
String pass : Password.

SubscribeToNode(int nodeId)

This does a subscription to the node with the specified ID. After this we will receive events associated to any change performed in the node.

int nodeId : Unique ID of the node we want to subscribe to.

UnsubscribeFromNode(int nodeId)

Cancels the subscription with the node with the specified ID.

int nodeId : Unique ID of the node we want to unsubscribe from.

SendObject(int nodeId, Object data)

Sends data to the node with the specified ID. Any data type can be sent but there are some compatibility issues to take into account (See the end of this document).

int nodeId : Unique ID of the node we want to send data to.
Object data : Data.

LeaveNode(int nodeId)

Removes our node from the node list of the specified node.

int nodeId : Unique ID of the node we want to exit from.

CreateNode(int nodeId, String name, Object param)

Creates a new node with the name and attributes specified, and adds it to the node list of the node with the specified ID.

int nodeId : Unique ID of the parent node.
String name : New node name.
Object param : Default attributes for the new node.

DestroyNode(int nodeId)

Destroys the node with the specified ID.

int nodeId : The node ID of the node we want to destroy.

SetAttribute(int nodeId, String name, Object value)

Changes the value of the attribute with the specified name in the node with the specified ID. If the attribute doesn't exists, a new attribute is created, if the value is null, the attribute is destroyed.

int nodeId : Unique ID of the node.
String name : Name of the attribute.
Object value : New attribute value.

SetChildAttribute(int nodeId, int childId, String name, Object value)

Changes the value of the attribute with the specified name in the node with the specified ID (childId), inside the node list of the node with the specified ID (nodeId). If the attribute doesn't exists, a new attribute is created, if the value is null, the attribute is destroyed.

int nodeId : Unique ID of the parent node.
int childId : Unique ID of the node which owns the attribute.
String name : Attribute name.
Object value : Attribute new value.

FindNodeByName(String name)

Sends a search request to look for a node by its name. The search context is global, searching in all the server structure. This method will generate an OnNodeFound event.

String name : Node name.

BeamClientListener interface

void OnLogin(int sender, String result, int nodeId)

int sender : Event origin node.
String result : Request result.

int nodeId : My own ID, if success.

void OnJoinNode(int sender, Boolean success, int nodeId)

int sender : Event origin node.
Boolean success : Success or failure of the operation.

int nodeId : My own ID.

void OnNodeAdded(int sender, int nodeId, String name, Hashtable param)

int sender : Event origin node.
int nodeId : New node Id.
String name : New node name.

Hashtable param : New node Attributes.

void OnNodeRemoved(int sender, int nodeId)

int sender : Event origin node.

int nodeId : Removed node ID.

void OnChildAttributeUpdated(int sender, int nodeId, String name, Object value)

int sender : Event origin node.
int nodeId : Modified node ID.
String name : Attribute name.

Object value : New attribute value.

void OnAttributeUpdated(int sender, String name, Object value)

int sender : Event origin node.
String name : Attribute name.

Object value : New attribute value.

void OnObjectReceived(int sender, int codec, Object data)

int sender : Event origin node.
int codec : Data type.

Object data : Received data.

void OnLeaveNode(int sender)

int sender : Event origin node.

void OnNodeDestroyed(int sender, int nodeId)

int sender : Event origin node.

int nodeId : Destroyed node ID.
void OnConnect()
void OnDisconnect()

void OnNodeFound(int sender, bool found, int nodeId)

int sender : Event origin node.

bool found : True or False.

int nodeId : Node ID if found, 0 otherwise.