3.1.4
const for datalink protocol for web sockets, DataLink1.0
Type: string
enum for modes, either QUERY or STREAM
const for query mode, QUERY
const for streaming mode, STREAM
const for maximum process number to create fake number for datalink id, 2^16-2
const for fake user name for datalink id, browser
Type: string
const for fake program name for datalink id, seisplotjs
Type: string
const for fake architecture for datalink id, javascript
Type: string
const for error response, ERROR
Type: string
const for ok response, OK
Type: string
const for info response, INFO
Type: string
const for id response, ID
Type: string
Type: string
Type: string
Type: string
Type: string
Type: string
Type: string
A websocket based Datalink connection.
Note this cannot connect directly to a native TCP socket, instead it sends the datalink protocol over a websocket.
Currently only the IRIS ringserver, https://github.com/iris-edu/ringserver, supports websockets, but it may be possible to use thrid party tools to proxy the websocket to a TCP datalink socket.
The datalink protocol is documented here https://earthscope.github.io/libdali/datalink-protocol.html
(string)
websocket url to the ringserver
(function (packet: DataLinkPacket): void)
callback for packets as they arrive
(function (error: Error): void)
callback for errors
Makes sure a response actually is a DataLinkResponse
((DataLinkResponse | DataLinkPacket))
datalink packet/response
DataLinkResponse
:
DataLinkResponse after checking instanceof
Makes sure a response actually is a DataLinkPacket
((DataLinkResponse | DataLinkPacket))
datalink packet/response
DataLinkPacket
:
DataLinkPacket after checking instanceof
Type: function (packet: DataLinkPacket): void
Type: (null | function (close: CloseEvent): void)
Set a callback function called when the connection is closed.
(function (close: CloseEvent): void)
callback function
Switches to streaming mode to receive data packets from the ringserver.
Promise<DataLinkResponse>
:
promise to the response
Switches back to query mode to enable commands to be sent to the ringserver.
void
Closes the connection and the underlying websocket. No communication is possible until connect() is called again.
void
encodes as a Datalink packet, header with optional data section as binary Uint8Array. Size of the binary data is appended to the header if present.
(string)
the command/header string
(Uint8Array?)
optional data portion
ArrayBuffer
:
datalink packet as an ArrayBuffer
sends the header with optional binary data as the data section. Size of the data is appended to the header before sending if present.
(string)
header to send
(Uint8Array?)
optional data to send
void
sends the command as header with optional dataString as the data section. Size of the dataString is appended to the header before sending.
void
Send a DataLink Command and await the response. Command is a string.
(string)
packet header
(Uint8Array?)
optional data portion of packet
Promise<(DataLinkResponse | DataLinkPacket)>
:
a Promise that resolves with the webSocket MessageEvent.
Send a DataLink Command and await the response. Command is a string. Returns a Promise that resolves with the webSocket MessageEvent.
Promise<(DataLinkResponse | DataLinkPacket)>
:
promise to server's response
Writes data to the ringserver and awaits a acknowledgement.
(string)
stream id for packet header
(DateTime)
start of timewindow the packet covers
(DateTime)
end of timewindow the packet covers
(Uint8Array?)
optional data to send
Promise<(DataLinkResponse | DataLinkPacket)>
:
promise to server's response
Send id and await server's response. All of these are can more or less be filled with dummy values. They are mostly used for logging and debugging on the server side.
(string)
name of program, ex seisplotjs
(string)
name of user, ex browser
(string)
process number, used to differentiate between multiple running instances
(string)
cpu architecture, ex javascript
Promise<DataLinkResponse>
:
promise to servers response
Send info command for infoType.
(string)
type to get info for
Promise<DataLinkResponse>
:
promise to server's response
Promise<StatusResponse>
Promise<StreamsResponse>
Promise<ConnectionsResponse>
Send position after command.
(DateTime)
time to position after
Promise<DataLinkResponse>
:
promise to server's response
Send position after command.
(number)
time to position after
Promise<DataLinkResponse>
:
promise to server's response
Send match command.
(string)
regular expression to match streams
Promise<DataLinkResponse>
:
promise to server's response
Send reject command.
(string)
regular expression to reject streams
Promise<DataLinkResponse>
:
promise to server's response
Read a single packet for the given id.
(string)
id of the packet of interest
Promise<DataLinkPacket>
:
promise to server's response
(ArrayBuffer)
void
Datalink response, used for ID, INFO, OK and ERROR responses.
DataLinkResponse
Represents a Datalink packet from the ringserver.
Type: (null | miniseed.DataRecord)
Type: (null | mseed3.MSeed3Record)
Packet start time as a DateTime.
Type: DateTime
DateTime
:
start time
Packet end time as a DateTime.
Type: DateTime
DateTime
:
end time
Packet time as a DateTime.
Type: DateTime
DateTime
:
packet time
Parsed payload as a miniseed data record, if the streamid ends with '/MSEED', null otherwise.
(miniseed.DataRecord | null)
:
miniseed DataRecord or null
Parsed payload as a miniseed3 data record, if the data format is 3, null otherwise.
(mseed3.MSeed3Record | null)
:
miniseed3 DataRecord or null
Parses the attributes of a xml element.
(Element)
DataLink XML element
DataLinkIdStats
:
the id stats
(DateTime)
(string)
(number)
(number)
(number)
(number)
(boolean)
(boolean)
(number)
(number)
(number)
(number)
(number)
(number)
(number)
(DateTime)
(DateTime)
(DateTime)
(number)
(DateTime)
(DateTime)
(DateTime)
Parses the attributes of a xml element.
(Element)
DataLink
XML element
DataLinkStats
:
the stats
Type: DateTime
Type: DateTime
Type: DateTime
Type: DateTime
Type: DateTime
Type: DateTime
Type: DateTime
Parses the attributes of a xml element.
(Element)
DataLink
XML element
ThreadStat
:
the stats
(DataLinkResponse)
StatusResponse
(Element)
StatusResponse
Type: DataLinkIdStats
Type: DataLinkStats
Type: Array<ThreadStat>
(string)
(number)
(DateTime)
(DateTime)
(number)
(DateTime)
(DateTime)
(number)
(Element)
StreamStat
Type: DateTime
Type: DateTime
Type: DateTime
Type: DateTime
(DataLinkStats)
(Array<StreamStat>)
(DataLinkResponse)
StreamsResponse
(Element)
StreamsResponse
Type: DataLinkStats
Type: Array<StreamStat>
Non implementation, just stores xml as a string. Unlikely to be useful remotely as ringserver doesn't allow.
(string)
raw xml form server
(DataLinkResponse)
ConnectionsResponse
(Element)
ConnectionsResponse
Convert DataLink style dates, like "2022-10-04 15:11:24.786990" to ISO form for DateTime
(string)
datalink time
DateTime
:
DateTime
Convert DateTime to a HPTime number.
(DateTime)
DateTime to convert
number
:
microseconds since epoch
Convert hptime number to a DateTime.
(number)
hptime to convert
DateTime
:
DateTime in utc for the hptime
Encode string into a Uint8Array.
(string?)
String to encode.
Uint8Array
:
String as bytes in Uint8Array.