Installation Instructiosn
General Instructions
One of the following:
npm install corelink-client
Usage Instructions
API reference
TCP Sender and Receiver Walkthrough
Sender Walkthrough
First import corelink
Then define some constants. You will definitely need a server and a cert that authenticates into that server in order to send data.
const config = {
ControlPort: 20012,
/* ControlIP: '127.0.0.1', */
ControlIP: 'corelink.hpc.nyu.edu',
autoReconnect: false,
cert: '<corelink-tools-repo>/config/ca-crt.pem'
}
setInterval()
function)
const run = async () => {
let sender
if (await corelink.connect({ username: 'Testuser', password: 'Testpassword' }, config).catch((err) => { console.log(err) })) {
sender = await corelink.createSender({
workspace,
protocol,
type: datatype,
metadata: { name: 'Random Data' },
}).catch((err) => { console.log(err) })
}
setInterval(() => corelink.send(sender, Buffer.from(randomdata())), 1000)
}
run()
Receiver Walkthrough
You always have to import the library.
These are the same constants as the sender
const config = {
ControlPort: 20012,
/* ControlIP: '127.0.0.1', */
ControlIP: 'corelink.hpc.nyu.edu',
autoReconnect: false,
cert: '<corelink-tools-repo>/config/ca-crt.pem'
}
const run = async () => {
if (await corelink.connect({ username: 'Testuser', password: 'Testpassword' }, config).catch((err) => { console.log(err) })) {
await corelink.createReceiver({
workspace, protocol, type: datatype, echo: true, alert: true,
}).catch((err) => { console.log(err) })
corelink.on('receiver', async (data) => {
const options = { streamIDs: [data.streamID] }
await corelink.subscribe(options)
})
corelink.on('data', (streamID, data, header) => {
console.log(streamID, data.toString(), JSON.stringify(header))
})
}
}
run()
Source
You can read the code in the examples repository