Ejemplo n.º 1
0
  /**
   * Stops the provided protocol instance
   *
   * @param handle An object provided at the connection time, that identifies the connection that is
   *     to be stopped
   */
  public static void requestStopProtocol(ProtocolHandle handle) {

    BasePlugin.logDebugMessage(
        "ProtocolActionDelegate",
        "A user is requesting to stop the protocol identified by " + handle);
    ClientModel clientModel = ClientModel.getInstance();
    clientModel.requestStopProtocol(handle);

    ServerModel serverModel = ServerModel.getInstance();
    serverModel.stopListeningToPort(handle);
  }
Ejemplo n.º 2
0
  /**
   * Restarts the provided protocol instance
   *
   * @param handle An object provided at the connection time, that identifies the connection that is
   *     to be restarted
   */
  public static void requestRestartProtocol(ProtocolHandle handle) {

    BasePlugin.logDebugMessage(
        "ProtocolActionDelegate",
        "An user is requesting to restart the protocol identified by " + handle);

    ClientModel clientModel = ClientModel.getInstance();
    clientModel.requestRestartProtocol(handle);

    ServerModel serverModel = ServerModel.getInstance();
    serverModel.requestRestartProtocol(handle);
  }
Ejemplo n.º 3
0
  /**
   * Starts a protocol, taking part as server in the communication
   *
   * @param portToBind The local port where to bind the server to
   * @param allMessages A map containing all messages that belong to the protocol. The message code
   *     as key
   * @param incomingMessages A collection containing the message ids of all incoming messages. The
   *     message ids much match the id field in a ProtocolMsgDefinition object from the allMessages
   *     map
   * @param outgoingMessages A collection containing the message ids of all outgoing messages. The
   *     message ids much match the id field in a ProtocolMsgDefinition object from the allMessages
   *     map
   * @param protocolInitializer The sequence of steps to execute for connection initialization
   * @param isBigEndianProtocol True if the protocol is big endian, false if little endian
   * @return A handle to identify the connection just made
   */
  public static ProtocolHandle requestStartProtocolAsServer(
      int portToBind,
      Map<Long, ProtocolMsgDefinition> allMessages,
      Collection<String> incomingMessages,
      Collection<String> outgoingMessages,
      IProtocolHandshake protocolInitializer,
      IProtocolExceptionHandler exceptionHandler,
      boolean isBigEndianProtocol) {

    BasePlugin.logDebugMessage(
        "ProtocolActionDelegate",
        "An user is requesting to start a server protocol at port " + portToBind + ".");
    ServerModel model = ServerModel.getInstance();
    return model.startListeningToPort(
        portToBind,
        allMessages,
        incomingMessages,
        outgoingMessages,
        protocolInitializer,
        exceptionHandler,
        isBigEndianProtocol);
  }
Ejemplo n.º 4
0
 /**
  * Tests if the protocol identified by handle is running or not
  *
  * @param handle The handle that identifies a protocol instance
  * @return True if the protocol is running, false otherwise
  */
 public static boolean isProtocolRunning(ProtocolHandle handle) {
   return ClientModel.getInstance().isClientProtocolRunning(handle)
       || ServerModel.getInstance().isListeningToPort(handle);
 }