Initiate Stream
Initiating a stream creates a bidirectional socket from the client and the Marsview Server. The client will stream Audio data in real-time to the Marsview service endpoint, The Marsview server will send Model Outputs and Transcript back to the client on the same socket connection.

Initiate Stream code in Node.js

The example code below uses to stream data to and from the Marsview Server.
const express = require('express');
const app = express();
const port = 1337;
const server = require('http').createServer(app);
const ioClient = require('')
const session = require("express-session");
const wrap = middleware => (socket, next) => middleware(socket.request, {}, next);
const io = require('')(server);
const io_client = ioClient.connect('', {
auth: {
token: <ATUHTOKEN>,
channelId: <CHANNEL ID>
io_client.on('valid-token', function (data) {
console.log('Token is valid');
io_client.on('invalid-token', function (data) {
console.log("Invalid token")
io_client.emit('startStream', data)
The above connection is used to establish a websocket connection with the Marsview Realtime API endpoint. When once the connection is established we can user the io_client object to stream data to and from the Marsview Realtime API endpoint. The websocket call made to startStream is used to open up an end point that can receive the audio input from the client side.
The input data fed into the stream from the client side will be byte data/byte array the client receives from various sources. The input byte array can be streamed to Marsview using the websocket key binaryData .

Code Block for emitting byte array

io_client.emit('binaryData', data)
This code block would be plugged into a streaming data input. Each time a byte array comes into the client side code this line of code has to be executed. Heredata is the byte array.