Class Context

java.lang.Object
com.bytedesk.call.esl.client.internal.Context
All Implemented Interfaces:
IModEslApi

public class Context extends Object implements IModEslApi
  • Field Details

  • Constructor Details

  • Method Details

    • canSend

      public boolean canSend()
      Specified by:
      canSend in interface IModEslApi
    • sendCommand

      public EslMessage sendCommand(String command)
      Sends a mod_event_socket command to FreeSWITCH server and blocks, waiting for an immediate response from the server.

      The outcome of the command from the server is returned in an EslMessage object.

      Parameters:
      command - a mod_event_socket command to send
      Returns:
      an EslMessage containing command results
    • sendApiCommand

      public EslMessage sendApiCommand(String command, String arg)
      Sends a FreeSWITCH API command to the server and blocks, waiting for an immediate response from the server.

      The outcome of the command from the server is returned in an EslMessage object.

      Specified by:
      sendApiCommand in interface IModEslApi
      Parameters:
      command - API command to send
      arg - command arguments
      Returns:
      an EslMessage containing command results
    • sendBackgroundApiCommand

      public CompletableFuture<EslEvent> sendBackgroundApiCommand(String command, String arg)
      Submit a FreeSWITCH API command to the server to be executed in background mode. A synchronous response from the server provides a UUID to identify the job execution results. When the server has completed the job execution it fires a BACKGROUND_JOB Event with the execution results.

      Note that this Client must be subscribed in the normal way to BACKGROUND_JOB Events, in order to receive this event.

      Specified by:
      sendBackgroundApiCommand in interface IModEslApi
      Parameters:
      command - API command to send
      arg - command arguments
      Returns:
      String Job-UUID that the server will tag result event with.
    • setEventSubscriptions

      public CommandResponse setEventSubscriptions(IModEslApi.EventFormat format, String events)
      Set the current event subscription for this connection to the server. Examples of the events argument are:
         ALL
         CHANNEL_CREATE CHANNEL_DESTROY HEARTBEAT
         CUSTOM conference::maintenance
         CHANNEL_CREATE CHANNEL_DESTROY CUSTOM conference::maintenance sofia::register sofia::expire
       
      Subsequent calls to this method replaces any previous subscriptions that were set.

      Note: current implementation can only process 'plain' events.
      Specified by:
      setEventSubscriptions in interface IModEslApi
      Parameters:
      format - can be { plain | xml }
      events - { all | space separated list of events }
      Returns:
      a CommandResponse with the server's response.
    • cancelEventSubscriptions

      public CommandResponse cancelEventSubscriptions()
      Cancel any existing event subscription.
      Specified by:
      cancelEventSubscriptions in interface IModEslApi
      Returns:
      a CommandResponse with the server's response.
    • addEventFilter

      public CommandResponse addEventFilter(String eventHeader, String valueToFilter)
      Add an event filter to the current set of event filters on this connection. Any of the event headers can be used as a filter.

      Note that event filters follow 'filter-in' semantics. That is, when a filter is applied only the filtered values will be received. Multiple filters can be added to the current connection.

      Example filters:
          eventHeader        valueToFilter
          ----------------------------------
          Event-Name         CHANNEL_EXECUTE
          Channel-State      CS_NEW
       
      Specified by:
      addEventFilter in interface IModEslApi
      Parameters:
      eventHeader - to filter on
      valueToFilter - the value to match
      Returns:
      a CommandResponse with the server's response.
    • deleteEventFilter

      public CommandResponse deleteEventFilter(String eventHeader, String valueToFilter)
      Delete an event filter from the current set of event filters on this connection. See
      Specified by:
      deleteEventFilter in interface IModEslApi
      Parameters:
      eventHeader - to remove
      valueToFilter - to remove
      Returns:
      a CommandResponse with the server's response.
    • sendMessage

      public CommandResponse sendMessage(SendMsg sendMsg)
      Send a SendMsg command to FreeSWITCH. This client requires that the SendMsg has a call UUID parameter.
      Specified by:
      sendMessage in interface IModEslApi
      Parameters:
      sendMsg - a SendMsg with call UUID
      Returns:
      a CommandResponse with the server's response.
    • setLoggingLevel

      public CommandResponse setLoggingLevel(IModEslApi.LoggingLevel level)
      Enable log output.
      Specified by:
      setLoggingLevel in interface IModEslApi
      Parameters:
      level - using the same values as in console.conf
      Returns:
      a CommandResponse with the server's response.
    • cancelLogging

      public CommandResponse cancelLogging()
      Disable any logging previously enabled with setLogLevel().
      Specified by:
      cancelLogging in interface IModEslApi
      Returns:
      a CommandResponse with the server's response.
    • closeChannel

      public void closeChannel()