Functions of ballerina.net.ws package
function cancelHandshake(int statusCode, string reason)
Cancel the handshake
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
statusCode | int | Status code for closing the connection |
reason | string | Reason for closing the connection |
function closeConnection(int statusCode, string reason)
Close the connection
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
statusCode | int | Status code for closing the connection |
reason | string | Reason for closing the connection |
function getID() (string )
Get the ID of the WebSocket connection
Parameters:
Parameter Name | Data Type | Description |
---|
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | string: ID of the connection |
function getNegotiatedSubProtocol() (string )
Get the Negotiated sub protocol for given connection
Parameters:
Parameter Name | Data Type | Description |
---|
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | string: Negotiated sub protocol |
function getParentConnection() (Connection )
Get parent connection if exisits
Parameters:
Parameter Name | Data Type | Description |
---|
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
Connection | Connection: The parent connection if exisits else null |
function getUpgradeHeader(string key) (string )
Get a value of a header
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
key | string | Key of the header which the value should be retrieved |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | string: Value of the key if exists else null |
function getUpgradeHeaders() (map )
Get a map of all the upgrade headers of the connection
Parameters:
Parameter Name | Data Type | Description |
---|
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
map | map<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 Name | Data Type | Description |
---|
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean |
function isSecure() (boolean )
Check whether the connection is secured or not
Parameters:
Parameter Name | Data Type | Description |
---|
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean | boolean: true if the connection is secured |
function pushBinary(blob data)
Push binary data to the connection
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
data | blob | Binary data which should be sent |
function pushText(string text)
Push text to the connection
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
text | string | Text 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 Name | Data Type | Description |
---|---|---|
url | string | WebSocket url for the backend |
callbackService | string | Callback service to listen to the incoming messages from the backend |
action connect(ClientConnectorConfig config)
Connect to remote endpoint
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
config | ClientConnectorConfig |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
Connection | Connection: New WebSocket connection for the connected backend |
action connectWithDefault()
Connect to remote endpoint with default configuration
Parameters:
Parameter Name | Data Type | Description |
---|
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
Connection |
Structs of ballerina.net.ws package
struct BinaryFrame
Fields:
Field Name | Data Type | Description |
---|---|---|
data | blob | |
isFinalFragment | boolean |
struct ClientConnectorConfig
Fields:
Field Name | Data Type | Description |
---|---|---|
subProtocols | string[] | |
parentConnectionID | string | |
customHeaders | map | |
idleTimeoutInSeconds | int |
struct CloseFrame
Fields:
Field Name | Data Type | Description |
---|---|---|
statusCode | int | |
reason | string |
struct Connection
Fields:
Field Name | Data Type | Description |
---|---|---|
attributes | map |
struct HandshakeConnection
Fields:
Field Name | Data Type | Description |
---|---|---|
connectionID | string | |
isSecure | boolean | |
upgradeHeaders | map |
struct PingFrame
Fields:
Field Name | Data Type | Description |
---|---|---|
data | blob |
struct PongFrame
Fields:
Field Name | Data Type | Description |
---|---|---|
data | blob |
struct TextFrame
Fields:
Field Name | Data Type | Description |
---|---|---|
text | string | |
isFinalFragment | boolean |
Annotations of ballerina.net.ws package
annotation clientService
Attributes:
Attribute Name | Data Type | Description |
---|
annotation configuration
Attributes:
Attribute Name | Data Type | Description |
---|---|---|
basePath | string | |
subProtocols | string[] | |
host | string | |
port | int | |
wssPort | int | |
idleTimeoutInSeconds | int | |
keyStoreFile | string | |
keyStorePassword | string | |
certPassword | string |