Class AbstractMediaGatewayConnection

java.lang.Object
moe.kyokobot.koe.internal.gateway.AbstractMediaGatewayConnection
All Implemented Interfaces:
MediaGatewayConnection
Direct Known Subclasses:
MediaGatewayV4Connection, MediaGatewayV5Connection

public abstract class AbstractMediaGatewayConnection extends Object implements MediaGatewayConnection
  • Field Details

    • connection

      protected final MediaConnectionImpl connection
    • voiceServerInfo

      protected final VoiceServerInfo voiceServerInfo
    • websocketURI

      protected final URI websocketURI
    • bootstrap

      protected final io.netty.bootstrap.Bootstrap bootstrap
    • sslContext

      protected final io.netty.handler.ssl.SslContext sslContext
    • allocator

      protected final io.netty.buffer.ByteBufAllocator allocator
    • connectFuture

      protected final CompletableFuture<Void> connectFuture
    • version

      protected final int version
    • eventExecutor

      protected io.netty.util.concurrent.EventExecutor eventExecutor
    • channel

      protected io.netty.channel.Channel channel
    • connectAttempt

      protected int connectAttempt
    • resumable

      protected boolean resumable
  • Constructor Details

    • AbstractMediaGatewayConnection

      public AbstractMediaGatewayConnection(@NotNull @NotNull MediaConnectionImpl connection, @NotNull @NotNull VoiceServerInfo voiceServerInfo, int version)
  • Method Details

    • getValve

      @Nullable public @Nullable MediaValve getValve()
      Specified by:
      getValve in interface MediaGatewayConnection
      Returns:
      The MediaValve used by this connection, or null if this gateway version does not support it.
    • start

      public CompletableFuture<Void> start()
      Specified by:
      start in interface MediaGatewayConnection
    • close

      public void close(int code, @Nullable @Nullable String reason)
      Specified by:
      close in interface MediaGatewayConnection
    • reconnect

      public void reconnect()
      Specified by:
      reconnect in interface MediaGatewayConnection
    • isOpen

      public boolean isOpen()
      Specified by:
      isOpen in interface MediaGatewayConnection
    • getPing

      public long getPing()
      Specified by:
      getPing in interface MediaGatewayConnection
    • updateSpeaking

      public void updateSpeaking(int mask)
      Specified by:
      updateSpeaking in interface MediaGatewayConnection
    • identify

      protected void identify()
    • identifyPayload

      protected JsonObject identifyPayload()
    • resume

      protected void resume()
    • resumePayload

      protected JsonObject resumePayload()
    • heartbeatPayload

      protected Object heartbeatPayload()
    • codecs

      protected Collection<CodecInfo> codecs()
      Returns:
      the codecs announced when selecting the protocol
    • handlePayload

      protected void handlePayload(JsonObject object)
      Handles the opcodes all gateway versions share, newer versions override it to handle their own opcodes first.
    • handlePayload

      protected void handlePayload(io.netty.buffer.ByteBuf byteBuf)
    • onReady

      protected void onReady()
      Called after READY was dispatched, right before selecting the protocol.
    • onSessionDescription

      protected void onSessionDescription(JsonObject data)
      Called after the connection handler got the session description.
    • onStreamsChanged

      protected void onStreamsChanged(JsonObject payload)
      Called with the whole VIDEO payload, before the listeners are notified.
    • onUsersConnected

      protected void onUsersConnected(List<String> userIds)
      Called after the listeners were notified.
    • onUserDisconnected

      protected void onUserDisconnected(String userId)
      Called before the listeners are notified.
    • onProtocolSelected

      protected void onProtocolSelected()
      Called right after SELECT_PROTOCOL was sent, before announcing our streams.
    • onClose

      protected void onClose(int code, @Nullable @Nullable String reason, boolean remote)
    • sendInternalPayload

      public void sendInternalPayload(int op, Object d)
    • sendInternalBinPayload

      public void sendInternalBinPayload(int op, byte[] d)
    • sendRaw

      protected void sendRaw(JsonObject object)
    • sendRawBin

      protected void sendRawBin(io.netty.buffer.ByteBuf buffer)
    • stripScheme

      protected static String stripScheme(String endpoint)
      Strips the scheme from endpoints passed as a URL (e.g. "wss://host:443") instead of "host:port".
    • stripPort80

      protected static String stripPort80(String endpoint)