2.0.0
const for datalink protocol for web sockets, DataLink1.0
Type: string
const for query mode, QUERY
Type: string
const for streaming mode, STREAM
Type: string
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
Type: string
Type: string
Type: string
Type: string
Type: string
A websocket based Datalink connection to a ringserver. 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://raw.githubusercontent.com/iris-edu/libdali/master/doc/DataLink.protocol
(string)
websocket url to the ringserver
(function (packet: DataLinkPacket): void)
callback for packets as they arrive
(function (error: Error): void)
callback for errors
Type: function (packet: DataLinkPacket): void
Type: (null | function (close: CloseEvent): void)
Type: (null | function (response: DataLinkResponse): void)
Set a callback function called when the connection is closed.
(function (close: CloseEvent): void)
callback function
creates the websocket connection and sends the client ID.
any
:
a Promise that resolves to the server's ID.
any
:
the current mode, QUERY_MODE or STREAM_MODE
Switches to streaming mode to receive data packets from the ringserver.
void
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> | Promise<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> | Promise<DataLinkPacket>)
:
promise to server's response
Writes data to the ringserver and awaits a acknowledgement.
(string)
stream id for packet header
(number)
start of timewindow the packet covers
(number)
end of timewindow the packet covers
(Uint8Array?)
optional data to send
(Promise<DataLinkResponse> | Promise<DataLinkPacket>)
:
promise to server's response
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
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
Send position after command.
(moment)
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
Datalink response, used for ID, INFO, OK and ERROR responses.
DataLinkResponse
Represents a Datalink packet from the ringserver. Note this cannot connect directly to a native TCP socket, instead it sends the datalink protocol over a websocket. Currently only the IRIS ringserver supports websockets, but it may be possible to use thrid party tools to proxy the websocket to a TCP datalink socket.
Type: (null | miniseed.DataRecord)
Packet start time as a moment.
Type: moment
moment
:
start time
Packet end time as a moment.
Type: moment
moment
:
end time
Packet time as a moment.
Type: moment
moment
:
packet time
Parsed payload as a miniseed data record, if the streamid ends with '/MSEED', null otherwise.
any
:
miniseed DataRecord or null
Convert moment to a HPTime number.
(moment)
moment to convert
number
:
microseconds since epoch
Convert hptime number to a moment.
(number)
hptime to convert
moment
:
moment in utc for the hptime
Encode string into a Uint8Array.
(string?)
String to encode.
(Uint8Array | void)
:
String as bytes in Uint8Array.