API Docs for: 0.0.57
Show:

ClientTCP_transport Class

a ClientTCP_transport connects to a remote server socket and initiates a communication with a HEL/ACK transaction. It negociates the communication parameters with the other end.

Constructor

ClientTCP_transport

()

Example:

var transport = ClientTCP_transport(url);

transport.timeout = 1000;

transport.connect(function(err)) {
     if (err) {
        // cannot connect
     } else {
        // connected

     }
});
....

transport.write(message_chunk,'F');

....

transport.on("message",function(message_chunk) {
    // do something with message from server...
});


Methods

_install_socket

(
  • socket
)
protected

Parameters:

  • socket Socket

checkSelectClause

(
  • parentNode
  • selectClause
)
Array

Provided by the opcua.helpers module.

Defined in lib\tools\tools_event_filter.js:122

Parameters:

  • parentNode Object
  • selectClause Object

Returns:

Array:

checkSelectClauses

(
  • eventTypeNode
  • selectClauses
)
StatusCodes<>

Provided by the opcua.helpers module.

Defined in lib\tools\tools_event_filter.js:153

Parameters:

  • eventTypeNode Object
  • selectClauses SelectClauseResults

Returns:

StatusCodes<>:

connect

(
  • endpoint_url
  • callback
  • [options]
)
async

Parameters:

  • endpoint_url String
  • callback Function

    the callback function

  • [options] Object optional

constructEventFilter

()

Provided by the opcua.helpers module.

Defined in lib\tools\tools_event_filter.js:26

helper to construct event filters: construct a simple event filter

Example:

constructEventFilter(["SourceName","Message","ReceiveTime"]);

constructEventFilter(["SourceName",{namespaceIndex:2 , "MyData"}]);
constructEventFilter(["SourceName","2:MyData" ]);

constructEventFilter(["SourceName" ,["EnabledState","EffectiveDisplayName"] ]);
constructEventFilter(["SourceName" ,"EnabledState.EffectiveDisplayName" ]);

createChunk

(
  • msg_type
  • chunk_type
  • length
)
Buffer
`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 String
    chunk 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

(
  • callback
)
async
disconnect the TCP layer and close the underlying socket. The `"close"` event will be emitted to the observers with err=null.

Parameters:

  • callback Object

write

(
  • message_chunk
)
write the message_chunk on the socket.

Parameters:

  • message_chunk Buffer
    Notes: - 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

chunkSize

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 Object
    the Error object or null

connect

notify the observers that the transport is connected (the socket is connected and the the HEL/ACK transaction has been done)

connection_break

message

notify the observers that a message chunk has been received

Event Payload:

  • message_chunk Buffer
    the message chunk