Ballerina API Documentation

Functions of ballerina.net.ws package

function cancelHandshake(int statusCode, string reason)

Cancel the handshake

Parameters:

Parameter NameData TypeDescription
statusCodeintStatus code for closing the connection
reasonstringReason for closing the connection

function closeConnection(int statusCode, string reason)

Close the connection

Parameters:

Parameter NameData TypeDescription
statusCodeintStatus code for closing the connection
reasonstringReason for closing the connection

function getID() (string )

Get the ID of the WebSocket connection

Parameters:

Parameter NameData TypeDescription

Return Parameters:

Return VariableData TypeDescription
stringstring: ID of the connection

function getNegotiatedSubProtocol() (string )

Get the Negotiated sub protocol for given connection

Parameters:

Parameter NameData TypeDescription

Return Parameters:

Return VariableData TypeDescription
stringstring: Negotiated sub protocol

function getParentConnection() (Connection )

Get parent connection if exisits

Parameters:

Parameter NameData TypeDescription

Return Parameters:

Return VariableData TypeDescription
ConnectionConnection: The parent connection if exisits else null

function getUpgradeHeader(string key) (string )

Get a value of a header

Parameters:

Parameter NameData TypeDescription
keystringKey of the header which the value should be retrieved

Return Parameters:

Return VariableData TypeDescription
stringstring: Value of the key if exists else null

function getUpgradeHeaders() (map )

Get a map of all the upgrade headers of the connection

Parameters:

Parameter NameData TypeDescription

Return Parameters:

Return VariableData TypeDescription
mapmap<string>: Map of all the headers received in the connection upgrade

function isOpen() (boolean )

Check whether the connection is still open or not.

Parameters:

Parameter NameData TypeDescription

Return Parameters:

Return VariableData TypeDescription
boolean

function isSecure() (boolean )

Check whether the connection is secured or not

Parameters:

Parameter NameData TypeDescription

Return Parameters:

Return VariableData TypeDescription
booleanboolean: true if the connection is secured

function pushBinary(blob data)

Push binary data to the connection

Parameters:

Parameter NameData TypeDescription
datablobBinary data which should be sent

function pushText(string text)

Push text to the connection

Parameters:

Parameter NameData TypeDescription
textstringText which should be sent


Connectors of ballerina.net.ws package

connector ClientConnector (string url, string callbackService)

WebSocket client connector for connecting to WebSocket backend

Parameters:

Parameter NameData TypeDescription
urlstringWebSocket url for the backend
callbackServicestringCallback service to listen to the incoming messages from the backend

Actions:

action connect(ClientConnectorConfig config)

Connect to remote endpoint

Parameters:

Parameter NameData TypeDescription
configClientConnectorConfig

Return Parameters:

Return VariableData TypeDescription
ConnectionConnection: New WebSocket connection for the connected backend

action connectWithDefault()

Connect to remote endpoint with default configuration

Parameters:

Parameter NameData TypeDescription

Return Parameters:

Return VariableData TypeDescription
Connection


Structs of ballerina.net.ws package

struct BinaryFrame

Fields:

Field NameData TypeDescription
datablob
isFinalFragmentboolean

struct ClientConnectorConfig

Fields:

Field NameData TypeDescription
subProtocolsstring[]
parentConnectionIDstring
customHeadersmap
idleTimeoutInSecondsint

struct CloseFrame

Fields:

Field NameData TypeDescription
statusCodeint
reasonstring

struct Connection

Fields:

Field NameData TypeDescription
attributesmap

struct HandshakeConnection

Fields:

Field NameData TypeDescription
connectionIDstring
isSecureboolean
upgradeHeadersmap

struct PingFrame

Fields:

Field NameData TypeDescription
datablob

struct PongFrame

Fields:

Field NameData TypeDescription
datablob

struct TextFrame

Fields:

Field NameData TypeDescription
textstring
isFinalFragmentboolean


Annotations of ballerina.net.ws package

annotation clientService

Attributes:

Attribute NameData TypeDescription

annotation configuration

Attributes:

Attribute NameData TypeDescription
basePathstring
subProtocolsstring[]
hoststring
portint
wssPortint
idleTimeoutInSecondsint
keyStoreFilestring
keyStorePasswordstring
certPasswordstring


Menu

  • Functions
    • cancelHandshake(int statusCode, string reason)
    • closeConnection(int statusCode, string reason)
    • getID() (string )
    • getNegotiatedSubProtocol() (string )
    • getParentConnection() (Connection )
    • getUpgradeHeader(string key) (string )
    • getUpgradeHeaders() (map )
    • isOpen() (boolean )
    • isSecure() (boolean )
    • pushBinary(blob data)
    • pushText(string text)
  • Connectors
    • ClientConnector (string url, string callbackService)
      • connect()
      • connectWithDefault()
  • Structs
    • BinaryFrame
    • ClientConnectorConfig
    • CloseFrame
    • Connection
    • HandshakeConnection
    • PingFrame
    • PongFrame
    • TextFrame
  • Annotations
    • clientService
    • configuration

Copyright 2017 Ballerina API Documentation