Skip to main content

Server API

import { Server } from 'iosignal';
const server = new Server({ port: 7777 });
// When the application shuts down:
// server.close(() => console.log('Server closed'));

Provide at least one transport option: port, httpServer, or congPort. port opens WebSocket; httpServer attaches to an existing HTTP server, with wsPath selecting the upgrade path; congPort serves the Arduino TCP transport.

OptionMeaning
timeout, monitorPeriodMilliseconds; constructor values must be at least 1000
showMessage, showMetricMessage and metric logging
membersOnlyRequire authentication; configure an authentication provider
pingTimeoutGraceFinite, nonnegative heartbeat grace
security.maxClockSkewMsPositive safe integer clock-skew limit
security.authChallengeMaxAgeMsPositive safe integer challenge lifetime
security.maxReplayEntriesPositive safe integer replay-cache capacity

Consult the installed 7.2.0 serverOption defaults before overriding limits. close(callback) closes the server and calls the callback after shutdown. For authenticated deployments, pass a BohoAuth instance as the second constructor argument; see authentication.

Services​

server.attach(name, service) registers an application service. A service exposes its allowed commands and may implement checkPermission(remote, req). Dispatch uses named command methods or the service's call(remote, req) entry point. Return responses through the installed implementation's replyService mechanism; inspect its types and service tests for the request/response contract.

Service authorization is an application responsibility. A generic IOSignal server does not automatically provide Remocon account-management APIs. See create a server for the runnable transport example.