Sleds/K2Client/java/com/sequencelogic/K2Client.java

79 lines
3.0 KiB
Java

package com.sequencelogic;
import java.util.Date;
import com.sequencelogic.K2Client;
import com.sequencelogic.K2ClientConstants;
public class K2Client
{
public static final int PORT_DEFAULT = K2ClientConstants.DEFAULT_UDP_PORT;
public static final String INFO_PREFIX = K2ClientConstants.MESSAGE_PREFIX_FROM_CLOUD;
public static final String INT_PREFIX = K2ClientConstants.MESSAGE_PREFIX_INTERNAL;
public static final String ERR_PREFIX = K2ClientConstants.MESSAGE_PREFIX_INTERNAL+K2ClientConstants.MESSAGE_2ND_PREFIX_FOR_ERRORS;
public static final String STATUS_PREFIX = K2ClientConstants.MESSAGE_PREFIX_DEVICE_STATUS;
/**
* The supplied class must provide a static method that takes a single String which is the "info"
* sent by the Daemon to this client.
* E.g. initialize("localhost:32000", "SyncAndMessageDispatch", "k2dataReceived")
* @param classLoader null or classLoader (Tomcat)
* @param hosts bar delimited set of hosts with optional ports
* @param urn device URN
*/
public native void initialize(Object classLoader, String callbackClassNameDotted, String hosts, String urn);
public native void shutdown();
public native void login();
public native void logout();
public native String statistics();
/**
* Get notified when an office in the provided list changes online/offline state.
* Your callbackClassNameDotted.k2dataReceived method will be invoked with:
* <p>
* 'status:' - <status value>:deviceURN for a device with a status change
* within an office subscribed via K2_StatusSelect(offices).
* </p>
* <p>
* <status value> may be one of the following:
* <ul>
* <li>'online' - device is online
* <li>'offline' - device is offline
* <li>Example: 'online:urn:sl:000000:F4685A6B:8F4D:'
* </ul>
* </p>
* @param offices comma delimited list of "urn:iono:000000:12345678::"
*/
public native void statusSelect(String offices);
/**
* Used only by CG.
*/
public native void pollDB();
static {
System.out.println("[JAVA] " + new Date() + " K2Client static init");
Exception here = new Exception("YOU ARE HERE: " + K2Client.class.getClassLoader());
here.fillInStackTrace();
//here.printStackTrace(System.out);
System.out.println("[JAVA] LD_LIBRARY_PATH (Linux): " + System.getenv("LD_LIBRARY_PATH"));
System.out.println("[JAVA] DYLD_LIBRARY_PATH (OSX): " + System.getenv("DYLD_LIBRARY_PATH"));
try
{
System.out.println("[JAVA] " + new Date() + " Loading K2Client... " + System.getProperty("java.library.path"));
System.loadLibrary("K2Client");
System.out.println("[JAVA] " + new Date() + " K2Client Loaded native libraries!");
}
catch (Throwable ex){
System.err.println("[JAVA] " + new Date() + " FATAL: K2Client Unable to load shared library: " + ex.getMessage());
ex.printStackTrace();
//throw ex;
}
}
public K2Client(){
//System.out.println("[JAVA] " + new Date() + " K2Client -CONSTRUCTED-");
}
}