📄 server.java
字号:
*
* public void Update(String aString)
* {
* this.setString(0, aString);
* updateService(service_id);
* }
* }
* </pre></blockquote>
*
*/
public static native int addService(String serviceName, String serviceType, DataEncoder theNativeDataEncoder);
// Note: we do not define an addService() method with a Memory parameter.
// Specifying only a method with a Memory type parameter, would not alow us to be informed when data is
// required. (Alowing the data to be tailored to the requesting user).
// If a Memory type parameter is beneficial for efficiency reasons, then the responsability for maintaining
// such a permanent reference to the Memory object can be given to the class implementing the DataEncoder.
// Example: see the class dim.test.StringService
/**
* adds a named command service to the server.
* @param commandName The name by which this command will be registered in the Dim Name Space (DNS) registry.
* @param commandType The type of the service, specifying the data format.
* @param theNativeDataDecoder An object that implements the DataDecoder interface and that
* will digest the Native data from a client command.
* @return The service registration ID.
*/
public static native int addCommand(String commandName, String commandType, DataDecoder theNativeDataDecoder);
// void add_client_exit_handler(void (*usr_routine)(...));
// void set_client_exit_handler(int conn_id, int tag);
// void add_exit_handler(void (*usr_routine)(...));
// void report_service(char *service_name);
/**
* Signals a specific client.
* @param service_id The service identification that was returned when the service was registered.
* @param client_id The internal connection number (as returned
* by get_client_connID() ) of the client that is to be notified.
*/
public static int selectiveUpdateService(int serviceId, int clientId) { return selectiveUpdateService(serviceId, new int[] {clientId, 0});}
/**
* Signals a selective list of clients.
* @param service_id The service identification that was returned when the service was registered.
* @param client_id_list The list that contains the internal connection number (as returned
* by get_client_connID() ) of the clients that are to be notified. Note: the last element of the list should
* contain zero.
*/
public static native int selectiveUpdateService(int serviceId, int[] clientIdList);
/**
* Signals all subscribing clients of the service.
* @param service_id The service identification that was returned when the service was registered.
*/
public static int updateService(int serviceId) { return selectiveUpdateService(serviceId, null); }
/**
* removes a previously registered information or command service.
* @param service_id The service identification that was returned when the service was registered.
*/
public static native void noPadding();
public static native int removeService(int serviceId);
/** @todo look at these not implemented server functions
* int get_next_cmnd(int *tag, int *buffer, int *size );
* public static native int find_service(string name);
* void add_client_exit_handler(void (*usr_routine)(...));
* void set_client_exit_handler(int conn_id, int tag);
* void add_exit_handler(void (*usr_routine)(...));
* void report_service(char *service_name);
* void send_service(int service_id, int *buffer, int size); // where is this used?
* int set_buffer_size(int size);
* void set_quality(int service_id, int quality);
* void set_timestamp(int service_id, int secs, int millisecs);
* void disable_padding();
*/
/**
* A simple class that provides an Object Oriented wrapper around the add_service function.
* <p>
* This class may in a future release be extended with convenience methods to inquire on
* properties such as name, connected clients, buffers etc.
* <p>
* In a future version this class will be extended with an autmatic call to remove the service once there
* are no more references to this class. To ensure continuation of the serivce, the user should keep
* a reference to this class as long as its services are required.
* <br>For performance and stability reasons, however, the user is encouraged to use the remove method
* explicitly and not to rely on the automatic clean up facility (which is not actually implemented).
* @see #addService
* @todo implement a getStatus method etc.
*/
public static class Info
{
/**
* The service_id off the service.
*/
private int serviceId;
/**
* Creates a new instance of a info service.
* @param serviceName The name by which this service will be registered in the Dim Name Space (DNS) registry.
* @param serviceType The type of the service, specifying the data format.
* @param theNativeDataEncoder An object that implements the DataEncoder interface and that
* will cook the Native data on request for a client.
* @see #addService addService
*/
public Info(String serviceName, String serviceType, DataEncoder theNativeDataEncoder)
{
serviceId = addService(serviceName, serviceType, theNativeDataEncoder);
}
/**
* Signals all subscribing clients of the service.
*/
public void update()
{
updateService(serviceId);
}
/**
* Signals a selected client only.
* @param client_id The internal connection number (as returned
* by get_client_connID() ) of the client that should be notified.
*/
public void selectiveUpdate(int clientId)
{
selectiveUpdateService(serviceId, new int[] {clientId, 0});
}
/**
* Signals a selective list of clients.
* @param client_id_list The list that contains the internal connection number (as returned
* by get_client_connID() ) of the clients that are to be notified.
*/
public void selectiveUpdate(int[] clientIdList)
{
selectiveUpdateService(serviceId, clientIdList);
}
/**
* Removes the registered service.
*/
public void remove()
{
removeService(serviceId);
}
}
/**
* A simple class that provides an Object Oriented wrapper around the add_cmnd function.
* <p>
* This class may in a future release be extended with convenience methods to inquire on
* properties such as name, connected clients, buffers etc.
* <p>
* In a future version this class will be extended with an autmatic call to remove the service once there
* are no more references to this class. To ensure continuation of the serivce, the user should keep
* a reference to this class as long as its services are required.
* <br>For performance and stability reasons, however, the user is encouraged to use the remove method
* explicitly and not to rely on the automatic clean up facility (which is not actually implemented).
* @see #addCommand
* @todo implement a getStatus method etc.
*/
public static class Command
{
/**
* The service_id off the service.
*/
private int serviceId;
/**
* Creates a new instance of command service to the server.
* @param commandName The name by which this command will be registered in the Dim Name Space (DNS) registry.
* @param serviceType The type of the service, specifying the data format.
* @param theNativeDataDecoder An object that implements the DataDecoder interface and that
* will digest the Native data from a client command.
* @see #addCommand addCommand
*/
public Command(String commandName, String commandType, DataDecoder theNativeDataDecoder)
{
serviceId = addCommand(commandName, commandType, theNativeDataDecoder);
}
/**
* Removes the registered service.
*/
public void remove()
{
removeService(serviceId);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -