ServerTCP_transport Class
Extends TCP_transport
Module: opcua.transport
Constructor
ServerTCP_transport
()
Item Index
Methods
- _install_one_time_message_receiver install a one time message receiver callback Rules: * TCP_transport will not emit the ```message``` event, while the "one time message receiver" is in operation. * the TCP_transport will wait for the next complete message chunk and call the provided callback func ```callback(null,messageChunk);``` * if a messageChunk is not received within ```TCP_transport.timeout``` or if the underlying socket reports an error, the callback function will be called with an Error.
- _install_socket
- createChunk
- disconnect
- init
- write
Properties
Events
Methods
_install_one_time_message_receiver
install a one time message receiver callback
Rules:
* TCP_transport will not emit the ```message``` event, while the "one time message receiver" is in operation.
* the TCP_transport will wait for the next complete message chunk and call the provided callback func
```callback(null,messageChunk);```
* if a messageChunk is not received within ```TCP_transport.timeout``` or if the underlying socket reports an error,
the callback function will be called with an Error.
(
protected
-
callback
Parameters:
-
callback
Functionthe callback function-
err
Null | Error -
messageChunk
Buffer | Null
-
_install_socket
(
protected
-
socket
Parameters:
-
socket
Socket
createChunk
(
Buffer
-
msg_type
-
chunk_type
-
length
`
createChunk`
is used to construct a pre-allocated chunk to store up to `
length`
bytes of data.
The created chunk includes a prepended header for `
chunk_type`
of size `
self.headerSize`
.
Parameters:
-
msg_type
Object -
chunk_type
Stringchunk type. should be 'F' 'C' or 'A' -
length
Object
Returns:
Buffer:
a buffer object with the required length representing the chunk.
Note:
- only one chunk can be created at a time.
- a created chunk should be committed using the
`
write`
method before an other one is created.
disconnect
(
async
-
callback
disconnect the TCP layer and close the underlying socket.
The
`
"close"`
event will be emitted to the observers with err=null.
Parameters:
-
callback
Object
init
(
-
socket
-
callback
Initialize the server transport.
The ServerTCP_transport initialisation process starts by waiting for the client to send a "HEL" message.
The ServerTCP_transport replies with a "ACK" message and then start waiting for further messages of any size.
The callback function received an error:
- if no message from the client is received within the
self.timeout
period, - or, if the connection has dropped within the same interval.
- if the protocol version specified within the HEL message is invalid or is greater than
self.protocolVersion
Parameters:
-
socket
Socket -
callback
Function-
err
Error | Nullerr = null if init succeeded
-
write
(
-
message_chunk
write the message_chunk on the socket.
Parameters:
-
message_chunk
BufferNotes: - the message chunk must have been created by`
createChunk`
. - once a message chunk has been written, it is possible to call`
createChunk`
again.
Properties
[timeout=30000]
Number
timeout
chunkReadCount
Number
chunkWrittenCount
Number
headerSize the size of the header in bytes
Number
Default: 8
protocolVersion indicates the version number of the OPCUA protocol used
Number
Default: 0
Events
close
notify the observers that the transport layer has been disconnected.
Event Payload:
-
err
Objectthe Error object or null
message
notify the observers that a message chunk has been received
Event Payload:
-
message_chunk
Bufferthe message chunk
socket_closed
notify the observers that the transport layer has been disconnected.
Event Payload:
-
err
Objectthe Error object or null