Structures

WSConnectionManager_typ

Name Type Description
in WSConnectionManager_In_typ Inputs for connection manager
out WSConnectionManager_Out_typ Outputs for connection manager
internal WSConnectionManager_Internal_typ Internal variables

WSConnectionManager.in

Name Type Description
cmd WSConnectionManager_In_Cmd_typ Commands for connection manager
cfg WSConnectionManager_In_Cfg_typ Configuration for connection manager

WSConnectionManager.in.cmd

Name Type Description
enable BOOL Enable connection manager
acknowledgeConnection BOOL Acknowledge new connection
acknowledgeError BOOL Acknowledge error

WSConnectionManager.in.cfg

Changes to cfg structure while socket is open causes socket to close and reopen.

Name Type Description
mode WS_Mode_enum Connection mode
localIPAddress STRING Local interface to open socket on. Default local IP can be determined automatically
localPort UDINT Local port to open socket on. Default local port can be determined automatically
remoteIPAddress STRING Remote interface to connect to. For Clients only
remotePort UDINT Remote port to connect to. For Clients only
sendBufferSize UDINT Adjusts the max. size of the transmit buffer. The default size should only be modified in certain applications, e.g. to optimize performance. The size should be a multiple of the MSS!
useSSL BOOL Use SSL encryption. Required for HTTPS connections
sslCertificate UDINT SSL Ident, refer to ArSslOpen (0 = default SSL configuration)

WSConnectionManager.out

Name Type Description
newConnectionAvailable BOOL Commands for connection manager
connection WSConnectionManager_Desc_typ Configuration for connection manager
error BOOL Error present
errorID UINT Error ID
errorString STRING Error description

WSConnectionManager_Desc_typ

Description

Name Type Description
parameters TCPConnection_Desc_typ TCP connection parameters
mode WS_Mode_enum WebSocket connection mode

WSStream_typ

Description

Name Type Description
in WSStream_IN_typ Inputs for WebSocket stream
out WSStream_Out_typ Outputs for WebSocket stream
internal WSStream_Internal_typ Internal variables

WSStream.in

Name Type Description
cmd WSStream_In_Cmd_typ Commands for WebSocket stream
par WSStream_In_Par_typ Parameters for WebSocket stream
cfg WSStream_In_Cfg_typ Configuration for WebSocket stream

WSStream.in.cmd

Name Type Description
receive BOOL Receive new messages. Level sensitive
send BOOL Send message
close BOOL Close current open connection
acknowledgeData BOOL Acknowledge received data. Only used when allowContinuousReceive is not used
acknowledgeError BOOL Acknowledge error

WSStream.in.par

Name Type Description
connection WSConnectionManager_Desc_typ Connection information
pReceiveData UDINT Pointer to buffer to be populated with received payload
maxReceiveLength UDINT Length of pReceiveData (sizeof()-1)
receiveFlags UINT TCP receive flags
allowContinuousReceive BOOL A new message will be received regardless if last message was acknowledged
pSendData UDINT Pointer to buffer populated with send payload to send
sendLength UDINT Length of payload to send
sendHeader WSHeader_typ WebSocket header to send. Not currently supported
sendFlags UINT TCP receive flags
allowContinuousSend BOOL Changes send from edge sensitive to a level sensitive command. Allows sending every cycle

WSStream.in.cfg

Name Type Description
bufferSize UDINT Size of internal buffer used for sending and receiving messages. Can not be changed after initialization

WSStream.out

Name Type Description
connection WSConnectionManager_Desc_typ Current active connection information
active BOOL Socket is open
connected BOOL WebSocket connection is established
receiving BOOL Receiving messages
header WSHeader_typ Received WebSocket header
partialDataReceived BOOL Partial data received. Header may be populated. Call again to get rest of message
dataReceived BOOL New message received
receivedDataLength UDINT Received payload length. Data copied into [pReceivedData]
sending BOOL Data is being sent
dataSent BOOL Data sent
sentDataLength UDINT Sent payload length
error BOOL Error present
errorID UINT Error ID
errorString STRING Error description

WSHeader_typ

Name Type Description
fin BOOL Last message in sequence
rsv USINT Reserved space. Can be used with some OpCodes
opCode USINT Message operation code
mask BOOL Mask message
maskingKey USINT[4] Masking key for encrypting message
frameLength UDINT Length of payload

WS_Mode_enum

Name Value Description
WS_MODE_SERVER 50000 WebSocket server mode
WS_MODE_CLIENT 50001 WebSocket client mode

WS_ERR_enum

Name Value Description
WS_ERR_OK 0 No Error
WS_ERR_INVALID_INPUT 5500 Invalid Input to FUB
WS_ERR_NOT_IMPLEMENTED 5501 Feature not yet implemented
WS_ERR_PAYLOAD_LENGTH 5502 Invalid payload length
WS_ERR_MEM_ALLOC 5503 Error allocating memory for buffers. Check BufferSize
WS_ERR_NO_LICENSE 5504 No license located on TG
WS_ERR_KEY_NOT_FOUND 5505 WebSocket key not found. Invalid update request
WS_ERR_PARTIAL_HTTP_MESSAGE 5506 Partial HTTP message received
WS_ERR_INVALID_HTTP_MESSAGE 5507 Invalid HTTP message received
WS_ERR_BUFFER_FULL 5508 Buffer full

WS_OpCode_enum

Name Value
WS_OPCODE_CONTINUATION 0
WS_OPCODE_TEXT 1
WS_OPCODE_BINARY 2
WS_OPCODE_RESERVED_NON_CONTROL 3
WS_OPCODE_CONNECTION_CLOSE 8
WS_OPCODE_PING 9
WS_OPCODE_PONG 10
WS_OPCODE_RESERVED_CONTROL 11