import java.net.*; import java.util.*; /** * This interface must be implemented by any adjunct software. *
* Implemented in javAPRSSrvr 3.0b01 and later. *
* Changed from 2.0: * Added portTable comment to getVersion description * Changed from 1.5: * init(String serverCall) added for global initialization. * String clientLogin dropped from instance init(). * Login(String clientLogin) added. * preProcess method added. * toClient method modified to take the Object from preProcess method. * Changed from 1.4: * init hostAddr parameter added. * toClient packetType and spclCall added. * Changed from 1.3: * getFilter added. * Changed from 1.2: * toClient path changed from Vector to String[]. * Changed from 1.1: * toClient return changed from boolean to String. **
* Synchronization Note: *
* It is expected that any thread-safe synchronization be done by the server adjunct. * For instance, it is possible that a setProperties, init, or setFilter may occur * at the same time as toClient. It is also possible for individual instances of * toClient may be entered concurrently. However, each instance of toClient will only * be entered once per packet and each packet will be processed sequentially. The * "global" instance of toClient will be called and returned before individual instances * will be called for the same packet. * * @author Peter Loveall AE5PL * @version 2.1 */ public interface ServerAdjunctInterface { // The following six methods are called from a single "global" instance // of the server adjunct. They should access global variables used // throughout all instances. /** * Global Only - Fills in status page with server adjunct info. *
* The format is the same as for portTable in javAPRSSrvr. * * @return String requested for display in status pages. */ public String getVersion(); /** * Global Only - Provides server adjunct specific properties. * * @return Properties specific to the server adjunct. */ public Properties getProperties(); /** * Global Only - Provides Properties loaded from the javAPRSSrvr configuration file. * * @param newProperties javAPRSSrvr Properties. */ public void setProperties(Properties newProperties); /** * Global Only - Gets default server adjunct Properties. * * @return Server Adjunct default properties. */ public Properties getDefaultProperties(); /** * Global Only - Initializes server adjunct. *
* Allows the server adjunct to initialize global fields. * * @param serverCall - Server login */ public void init(String serverCall); /** * Global Only - Processes all non-dupe packets passed through javAPRSSrvr. *
* This will always be passed a valid AX.25 packet. *
* All classes are subclasses of Object in Java so the return Object can be * any class defined in the server adjunct. This gives the SA author full control over * what will be passed to individual instances of toClient. * * @param fromCall Source callSSID. * @param toCall Destination callSSID. * @param path Via callSSIDs. * @param payload Index to all after the colon in orgPacket. * @param orgPacket Unmodified original packet. * @param CRC String made from the fromCall+" "+toCall+" "+CRC32(payload) * @param packetType Type of packet. Used to determine what spclCall is. 1 = Message, 2 = Object/Item, 0 = all others * @param spclCall packetType=1 -> msgToCall, packetType=2 -> objectName, packetType=0 -> null * * @return An Object to be passed to individual toClient. May be null. * * @see #toClient(Object processedObject) */ public Object preProcess(String fromCall, String toCall, String[] path, int payload, byte[] orgPacket, String CRC, int packetType, String spclCall); // The following methods are called from individual instances created // when a client connects. msgOnlyPorts, hubAndMsgPorts, clientOnlyPorts // readOnlyPorts, and filteredHistoryPorts support these calls. /** * Client Instance Only - Initializes server adjunct instance. *
* This is called when a connection is established. * * @param clientAddr IP of the client. * @param clientPort Port at the client end. * @param hostAddress IP of the host port if specified, otherwise null. * @param hostPort Host port the client is connected to. */ public void init(InetAddress clientAddr, int clientPort, InetAddress hostAddress, int hostPort); /** * Client Instance Only - Gives server adjunct instance the client login. *
* This is called when a login sequence is received by javAPRSSrvr * * @param clientLogin The client's login callSSID. */ public void Login(String clientLogin); /** * Client Instance Only - Executes server adjunct command processing. *
* This is passed a suspected server adjunct command string. *
* The suspected command comes from: * comment line text (all after #) * message text sent to SERVER or the server's callSSID * login text which follows "vers swtype swver" ** * @param cmdStart Points to the first byte in orgLine where the command may be. * @param cmdEnd points to 1 past the end of the command string (similar to String.substr). * If this is from a message packet, javAPRSSrvr will set cmdEnd to point to the beginning of the * sequence number because javAPRSSrvr will have to ack/rej the message anyway * otherwise, cmdEnd will be the length of orgLine * * @return A String response which can be sent to the client as-is. */ public String setFilter(int cmdStart, int cmdEnd, byte[] orgLine); /** * Client Instance Only - Displays current server adjunct setting(s). *
* This is for display in status pages and login responses. *
* This is NOT wrapped in try/catch block so be sure no exceptions occur here. * * @return The current server adjunct setting. No formatting is done here. * If no current setting, returns zero length string (must NOT return null). */ public String getFilter(); /** * Client Instance Only - Determines whether a packet should be passed to the client or not. * * @param processedObject Object returned by preProcess method. * * @return true -> pass the packet to the client. Default is false. */ public boolean toClient(Object processedObject); }