Class ProviderSelectorMessage

java.lang.Object
velox.api.layer1.providers.data.ProviderSelectorMessage

public class ProviderSelectorMessage extends Object

The message specifies that the next action relates to a specific provider (where it can't be derived from other data).

Examples of such events: Layer1ApiAdminListener.onLoginSuccessful() or Layer1ApiInstrumentListener.onInstrumentAdded(String, InstrumentInfo))

Here is how an addon can listen for Layer1ApiAdminListener.onConnectionLost(DisconnectionReason, String) - note how the sourceProvider is updated in onUserMessage(Object data) and later read in onConnectionLost(DisconnectionReason reason, String message)

   String sourceProvider;

   @Override
   public void onUserMessage(Object data) {
       if (data instanceof ProviderSelectorMessage) {
           ProviderSelectorMessage message = (ProviderSelectorMessage) data;
           sourceProvider = message.getProviderProgrammaticName();
       }
       super.onUserMessage(data);
   }

   @Override
   public void onConnectionLost(DisconnectionReason reason, String message) {
       super.onConnectionLost(reason, message);
       // You can do something more useful then simply logging the provider name
       Log.info("Connection lost for provider: " + sourceProvider);
   }
 
  • Field Details

    • sourceProviderType

      public final velox.api.layer1.data.ProviderType sourceProviderType
      This field is not intended for public API usage. Use getProviderProgrammaticName() instead.
  • Constructor Details

    • ProviderSelectorMessage

      public ProviderSelectorMessage(velox.api.layer1.data.ProviderType sourceProviderType)
      DO NOT use this directly, use ProviderType.getProviderSelectorMessage() instead - this way you'll avoid creating a new object every time.
      Parameters:
      sourceProviderType -
  • Method Details

    • createProviderSelectorMessage

      public static final ProviderSelectorMessage createProviderSelectorMessage(velox.api.layer1.data.ProviderType providerType)
      Returns provider selector messages of specific type. Objects are reused - same message is returned for same type
    • getProviderProgrammaticName

      public String getProviderProgrammaticName()
      Returns:
      unique string representation of a provider that caused an event, or null if the underlying provider is null