001package jmri.jmris.srcp;
002
003import jmri.InstanceManager;
004
005/**
006 * This class provides access to the service handlers for individual object
007 * types which can be passed to a parser visitor object.
008 *
009 * In addition to service handlers handling the connection's services, This
010 * class keeps track of connection details the parser visitor may be asked to
011 * return.
012 *
013 * @author Paul Bender Copyright (C) 2014
014 *
015 */
016public class JmriSRCPServiceHandler extends jmri.jmris.ServiceHandler {
017
018    public JmriSRCPServiceHandler(int port) {
019        super();
020        _session_number = port + (InstanceManager.getDefault(jmri.Timebase.class).getTime().getTime());
021    }
022
023    public long getSessionNumber() {
024        return _session_number;
025    }
026
027    private long _session_number = 0;
028
029    // _client_version holds the SRCP version the client supplied to the 
030    // server during handshake.
031    private String _client_version = "";
032
033    public String getClientVersion() {
034        return _client_version;
035    }
036
037    public void setClientVersion(String ver) {
038        _client_version = ver;
039    }
040
041    // runmode tells the server whether it is in handshake mode
042    // or run mode.
043    private boolean runmode = false;
044
045    // we can only set runmode to true, we can't go back to handshake mode.
046    public void setRunMode() {
047        runmode = true;
048    }
049
050    public boolean getRunMode() {
051        return runmode;
052    }
053
054    // commandMode tells the server whether it is in command mode or info
055    // mode, once runmode is set.  The default is command mode (per the protocol).
056    private boolean commandMode = true;
057
058    public boolean isCommandMode() {
059        return commandMode;
060    }
061
062    public void setCommandMode(boolean mode) {
063        commandMode = mode;
064    }
065
066}