Klasse TwitchPubSub

java.lang.Object
com.github.twitch4j.pubsub.TwitchPubSub
Alle implementierten Schnittstellen:
ITwitchPubSub, AutoCloseable

public class TwitchPubSub extends Object implements ITwitchPubSub
Twitch PubSub
  • Felddetails

    • REQUIRED_THREAD_COUNT

      public static final int REQUIRED_THREAD_COUNT
      Siehe auch:
    • queueTask

      protected final Future<?> queueTask
      Command Queue Thread
    • heartbeatTask

      protected final Future<?> heartbeatTask
      Heartbeat Thread
    • isClosed

      protected volatile boolean isClosed
      is Closed?
    • commandQueue

      protected final BlockingQueue<String> commandQueue
      Command Queue
    • subscribedTopics

      protected final Set<PubSubRequest> subscribedTopics
      Holds the subscribed topics in case we need to reconnect
    • lastPing

      protected volatile long lastPing
      Last Ping send (1 minute delay before sending the first ping)
    • lastPong

      protected volatile long lastPong
      Last Pong received
    • taskExecutor

      protected final ScheduledExecutorService taskExecutor
      Thread Pool Executor
  • Konstruktordetails

    • TwitchPubSub

      public TwitchPubSub(WebsocketConnection websocketConnection, EventManager eventManager, ScheduledThreadPoolExecutor taskExecutor, ProxyConfig proxyConfig, Collection<String> botOwnerIds, int wsPingPeriod, IBackoffStrategy connectionBackoffStrategy, int wsCloseDelay, Consumer<PubSubResponsePayload> fallbackTopicHandler)
      Constructor
      Parameter:
      websocketConnection - WebsocketConnection
      eventManager - EventManager
      taskExecutor - ScheduledThreadPoolExecutor
      proxyConfig - ProxyConfig
      botOwnerIds - Bot Owner IDs
      wsPingPeriod - WebSocket Ping Period
      connectionBackoffStrategy - WebSocket Connection Backoff Strategy
      wsCloseDelay - Websocket Close Delay
      fallbackTopicHandler - Fallback Topic Handler
  • Methodendetails

    • connect

      public void connect()
      Connecting to IRC-WS
    • disconnect

      public void disconnect()
      Disconnecting from WebSocket
    • reconnect

      public void reconnect()
      Reconnecting to WebSocket
    • onPreConnect

      protected void onPreConnect()
    • onConnected

      protected void onConnected()
    • onTextMessage

      protected void onTextMessage(String text)
    • listenOnTopic

      public PubSubSubscription listenOnTopic(PubSubRequest request)
      Beschreibung aus Schnittstelle kopiert: ITwitchPubSub
      Send WS Message to subscribe to a topic
      Angegeben von:
      listenOnTopic in Schnittstelle ITwitchPubSub
      Parameter:
      request - Topic
      Gibt zurück:
      PubSubSubscription to be listened to
    • unsubscribeFromTopic

      public boolean unsubscribeFromTopic(PubSubSubscription subscription)
      Beschreibung aus Schnittstelle kopiert: ITwitchPubSub
      Unsubscribe from a topic. Usage example:
            PubSubSubscription subscription = twitchPubSub.listenForCheerEvents(...);
            // ...
            twitchPubSub.unsubscribeFromTopic(subscription);
       
      Angegeben von:
      unsubscribeFromTopic in Schnittstelle ITwitchPubSub
      Parameter:
      subscription - PubSubSubscription to be unlistened from
      Gibt zurück:
      whether the subscription was previously subscribed to
    • getLatency

      public long getLatency()
      Angegeben von:
      getLatency in Schnittstelle ITwitchPubSub
      Gibt zurück:
      the most recently measured round-trip latency for the socket(s) in milliseconds, or -1 if unknown
    • close

      public void close()
      Close
      Angegeben von:
      close in Schnittstelle AutoCloseable
      Angegeben von:
      close in Schnittstelle ITwitchPubSub
    • getEventManager

      public EventManager getEventManager()
      EventManager
      Angegeben von:
      getEventManager in Schnittstelle ITwitchPubSub