Twitch SDK (Internal)
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ttv::binding::java::JavaWebSocket Class Reference

#include <java_socket.h>

Inheritance diagram for ttv::binding::java::JavaWebSocket:
ttv::IWebSocket ttv::binding::java::JavaSocketBase

Public Types

enum  MessageType { MessageType::None, MessageType::Binary, MessageType::Text, MessageType::Unknown }
 

Public Member Functions

 JavaWebSocket (JNIEnv *jEnv, jobject jInstance)
 
virtual ~JavaWebSocket ()
 
virtual TTV_ErrorCode Connect () override
 
virtual TTV_ErrorCode Disconnect () override
 
virtual TTV_ErrorCode Send (MessageType type, const uint8_t *buffer, size_t length) override
 
virtual TTV_ErrorCode Recv (MessageType &type, uint8_t *buffer, size_t length, size_t &received) override
 
virtual TTV_ErrorCode Peek (MessageType &type, size_t &length) override
 
virtual bool Connected () override
 
GlobalJavaObjectReferenceGetJavaInstance ()
 

Protected Member Functions

void AllocateByteArray (size_t size)
 

Protected Attributes

GlobalJavaObjectReference mSocketInstance
 The java implementation of the socket. More...
 
GlobalJavaObjectReference mSentReceivedResultContainer
 
GlobalJavaObjectReference mByteArrayInstance
 The scratch byte array. More...
 
size_t mByteArraySize
 The size of mByteArrayInstance. More...
 

Private Attributes

GlobalJavaObjectReference mMessageTypeResultContainer
 

Member Enumeration Documentation

◆ MessageType

enum ttv::IWebSocket::MessageType
stronginherited

The type of data in a frame.

Enumerator
None 

No data.

Binary 

A binary frame.

Text 

A text frame.

Unknown 

An unknown/unhandled frame type.

Constructor & Destructor Documentation

◆ JavaWebSocket()

ttv::binding::java::JavaWebSocket::JavaWebSocket ( JNIEnv *  jEnv,
jobject  jInstance 
)

◆ ~JavaWebSocket()

virtual ttv::binding::java::JavaWebSocket::~JavaWebSocket ( )
virtual

Member Function Documentation

◆ AllocateByteArray()

void ttv::binding::java::JavaSocketBase::AllocateByteArray ( size_t  size)
protectedinherited

◆ Connect()

virtual TTV_ErrorCode ttv::binding::java::JavaWebSocket::Connect ( )
overridevirtual

Synchronously connects to the endpoint.

See also
Disconnect
Returns
  • TTV_EC_SUCCESS: The socket has successfully connected and is ready to exchange data.
  • TTV_EC_SOCKET_EALREADY: Already connected.
  • TTV_EC_SOCKET_ETIMEDOUT: The connection timed out.
  • TTV_EC_SOCKET_ERR: A generic error occurred.

Implements ttv::IWebSocket.

◆ Connected()

virtual bool ttv::binding::java::JavaWebSocket::Connected ( )
overridevirtual

Determines if the socket is currently connected.

Returns
Whether or not currently connected.

Implements ttv::IWebSocket.

◆ Disconnect()

virtual TTV_ErrorCode ttv::binding::java::JavaWebSocket::Disconnect ( )
overridevirtual

Synchronously disconnects from the endpoint.

See also
Connect
Returns
  • TTV_EC_SUCCESS: The socket has successfully disconnected.
  • TTV_EC_SOCKET_ERR: A generic error occurred.

Implements ttv::IWebSocket.

◆ GetJavaInstance()

GlobalJavaObjectReference& ttv::binding::java::JavaSocketBase::GetJavaInstance ( )
inlineinherited

◆ Peek()

virtual TTV_ErrorCode ttv::binding::java::JavaWebSocket::Peek ( MessageType type,
size_t &  length 
)
overridevirtual

Determines the size and type of the next available message. If no messages are available then a message type of None will be returned.

See also
Recv
Parameters
[out]typeThe buffer to store the received bytes in.
[out]lengthThe number of bytes actually received.
Returns
  • TTV_EC_SUCCESS: Some bytes have been received.
  • TTV_EC_SOCKET_ENOTCONN: The socket is not connected.
  • TTV_EC_SOCKET_ECONNABORTED: The connected was dropped.
  • TTV_EC_SOCKET_ETIMEDOUT: The connection timed out.
  • TTV_EC_SOCKET_ECONNRESET: The connection was closed by the remote host.
  • TTV_EC_SOCKET_ERR: A generic error occurred.

Implements ttv::IWebSocket.

◆ Recv()

virtual TTV_ErrorCode ttv::binding::java::JavaWebSocket::Recv ( MessageType type,
uint8_t *  buffer,
size_t  length,
size_t &  received 
)
overridevirtual

Attempts to receive a message from the web socket. The next available message will be stored in buffer provided that it is large enough to store it. Use Peek() to determine how large of a buffer to provide. If the buffer is not large enough to hold the message then an error is returned and the message is not consumed.

See also
Peek
Parameters
[out]typeThe buffer to store the received bytes in.
[in]bufferThe buffer to store the received bytes in.
[in]lengthThe largest number of bytes to receive.
[out]receivedThe number of bytes actually received.
Returns
  • TTV_EC_SUCCESS: Some bytes have been received.
  • TTV_EC_SOCKET_ENOTCONN: The socket is not connected.
  • TTV_EC_SOCKET_ECONNABORTED: The connected was dropped.
  • TTV_EC_SOCKET_ETIMEDOUT: The connection timed out.
  • TTV_EC_SOCKET_ECONNRESET: The connection was closed by the remote host.
  • TTV_EC_SOCKET_ERR: A generic error occurred.
  • TTV_EC_INVALID_BUFFER: The given buffer is not big enough to store the next message.

Implements ttv::IWebSocket.

◆ Send()

virtual TTV_ErrorCode ttv::binding::java::JavaWebSocket::Send ( MessageType  type,
const uint8_t *  buffer,
size_t  length 
)
overridevirtual

Sends a message of the given type.

Parameters
[in]typeThe type of data represented by the buffer.
[in]bufferThe data to send.
[in]lengthThe number of bytes in the buffer.
Returns
  • TTV_EC_SUCCESS: The socket has successfully connected and is ready to exchange data.
  • TTV_EC_SUCCESS: The message has been sent.
  • TTV_EC_SOCKET_ENOTCONN: The socket is not connected.
  • TTV_EC_SOCKET_ECONNABORTED: The connected was dropped.
  • TTV_EC_SOCKET_ETIMEDOUT: The connection timed out.
  • TTV_EC_SOCKET_ECONNRESET: The connection was closed by the remote host.
  • TTV_EC_SOCKET_ERR: A generic error occurred.

Implements ttv::IWebSocket.

Member Data Documentation

◆ mByteArrayInstance

GlobalJavaObjectReference ttv::binding::java::JavaSocketBase::mByteArrayInstance
protectedinherited

The scratch byte array.

◆ mByteArraySize

size_t ttv::binding::java::JavaSocketBase::mByteArraySize
protectedinherited

The size of mByteArrayInstance.

◆ mMessageTypeResultContainer

GlobalJavaObjectReference ttv::binding::java::JavaWebSocket::mMessageTypeResultContainer
private

◆ mSentReceivedResultContainer

GlobalJavaObjectReference ttv::binding::java::JavaSocketBase::mSentReceivedResultContainer
protectedinherited

◆ mSocketInstance

GlobalJavaObjectReference ttv::binding::java::JavaSocketBase::mSocketInstance
protectedinherited

The java implementation of the socket.


The documentation for this class was generated from the following file: