Interface INetworkInstance

All Known Implementing Classes:
AbstractNetworkInstance

public interface INetworkInstance
To hold information about network

implement AbstractNetworkInstance if you want to implement only the necessary functions

use this interface if you want to do something completely different

  • Method Details

    • getRemoteVersions

      HashMap<Byte,Byte> getRemoteVersions()
      Get the version from the other side. null if default the map doesn't have to contain information about every module. these will be added automatically.

      do HashMap#put(3, 0) to disable sound streaming. NBS can't be optimized and often very large

      Returns:
      maybe null
    • setVersions

      void setVersions(HashMap<Byte,Byte> map)
      Receive (and save) versions from the other side
      Parameters:
      map - map
    • presenceResponse

      @Deprecated default void presenceResponse()
      Deprecated.
      communication changes
      Invoked after receiving the presence packet setVersions(HashMap) Used to send server-side config/emotes
    • sendPlayerID

      default boolean sendPlayerID()
      Do send the sender's id to the server
      Returns:
      true means send
    • sendMessage

      void sendMessage(EmotePacket.Builder builder, @Nullable @Nullable UUID target) throws IOException
      The Proxy controller ask you to send the message, only if isActive() is true
      Parameters:
      builder - packet builder
      target - target to send message, if null, everyone in the view distance on server-side target will be ignored
      Throws:
      IOException - when message write to bytes has failed
    • receiveMessage

      default void receiveMessage(ByteBuffer byteBuffer, UUID player)
      Network instance has received a message, it will send it to EmoteX core to execute you can set your receive event to invoke this there are it's other forms in AbstractNetworkInstance
      Parameters:
      byteBuffer - received buffer
      player - player who plays the emote, Can be NULL but only if trustReceivedPlayer() is true or message is not play or stop
    • sendC2SConfig

      default void sendC2SConfig(Consumer<EmotePacket.Builder> consumer)
      Client is sending config message to server. Vanilla clients will answer to the server configuration phase message. This might get invoked multiple times on the same network instance.
    • trustReceivedPlayer

      default boolean trustReceivedPlayer()
      when receiving a message, it contains a player. If you don't trust in this information, override this and return false
      Returns:
      false if received info is untrusted
    • isActive

      boolean isActive()
      Is the other side is available your send won't be invoke if you return false
      Returns:
      is this channel working
    • isServerTrackingPlayState

      boolean isServerTrackingPlayState()
      Does the track the emote play state of every player -> true The client has to resend the emote if a new player get close -> false
    • maxDataSize

      default int maxDataSize()
      Maximum size of the data what the instance can send

      Defaults to CommonData.MAX_PACKET_SIZE

      Returns:
      max size of bytes[]
    • safeGetBytesFromBuffer

      static byte[] safeGetBytesFromBuffer(ByteBuffer byteBuffer)
      If ByteBuffer is wrapped, it is safe to get the array but if is direct manual read is required.
      Parameters:
      byteBuffer - get the bytes from
      Returns:
      the byte array