BeamServer Java Client
The BeamServer Java Client API is based on the class BSClient and the interface BeamClientListener. 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.
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. int nodeId : My own ID, if success. |
void OnJoinNode(int sender, Boolean success, int nodeId) int sender : Event origin node. |
void OnNodeAdded(int sender, int nodeId, String name, Hashtable param) int sender : Event origin node. |
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. |
void OnAttributeUpdated(int sender, String name, Object value) int sender : Event origin node. |
void OnObjectReceived(int sender, int codec, Object data) int sender : Event origin node. |
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. |
Client-Server data transfer
Virtually any data type can be transferred, however we should take into account some platform compatibility issues.
.Net type Java type