feat(smart-app): implement complete mobile app MVP

- App.tsx: full navigation (Auth stack + Main tabs with 5 screens)
- Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen
- HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors
- MapScreen: interactive map with layer toggles (6 layers)
- MarketplaceScreen: categories (6), products (5), search
- ChatScreen: AI chat with quick prompts (4), bot responses
- ProfileScreen: user info, stats, menu (9 items), logout
- AlertsScreen: alert list with severity, acknowledge
- SensorsScreen: sensor list with type filters (6 types), search
- ZonesScreen: zone cards with stats
- SettingsScreen: language picker (FR/EN/ES/DE), privacy, about
- Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n
- Hooks: useSensors, useAlerts, useNotifications, useLocation
- Components: Card, Button, LoadingSpinner, ErrorBoundary, Header
- Services: iotService, notificationService (with axios API client)
- Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN)
- Theme: colors.ts with full design system (Blue Ocean palette)
- Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
This commit is contained in:
Eric FELIXINE
2026-06-01 18:00:35 -04:00
parent 08ca495bde
commit e30ae8ed09
35578 changed files with 3703534 additions and 43 deletions

View File

@@ -0,0 +1,14 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import ws from 'ws';
export default function createDebuggerProxyEndpoint(): {
server: ws.Server;
isDebuggerConnected: () => boolean;
};
//# sourceMappingURL=createDebuggerProxyEndpoint.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createDebuggerProxyEndpoint.d.ts","sourceRoot":"","sources":["../../src/websocket/createDebuggerProxyEndpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AAGpB,MAAM,CAAC,OAAO,UAAU,2BAA2B,IAAI;IACrD,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC;IAClB,mBAAmB,EAAE,MAAM,OAAO,CAAC;CACpC,CAsEA"}

View File

@@ -0,0 +1,104 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = createDebuggerProxyEndpoint;
function _ws() {
const data = _interopRequireDefault(require("ws"));
_ws = function () {
return data;
};
return data;
}
function _cliTools() {
const data = require("@react-native-community/cli-tools");
_cliTools = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
function createDebuggerProxyEndpoint() {
const WebSocketServer = _ws().default.Server;
const wss = new WebSocketServer({
noServer: true
});
let debuggerSocket;
let clientSocket;
function send(dest, message) {
if (!dest) {
return;
}
try {
dest.send(message);
} catch (e) {
_cliTools().logger.warn(e);
// Sometimes this call throws 'not opened'
}
}
const debuggerSocketCloseHandler = () => {
debuggerSocket = null;
if (clientSocket) {
clientSocket.close(1011, 'Debugger was disconnected');
}
};
const clientSocketCloseHandler = () => {
clientSocket = null;
send(debuggerSocket, JSON.stringify({
method: '$disconnected'
}));
};
wss.on('connection', (socket, request) => {
const {
url
} = request;
if (url && url.indexOf('role=debugger') > -1) {
if (debuggerSocket) {
socket.close(1011, 'Another debugger is already connected');
return;
}
debuggerSocket = socket;
if (debuggerSocket) {
debuggerSocket.onerror = debuggerSocketCloseHandler;
debuggerSocket.onclose = debuggerSocketCloseHandler;
debuggerSocket.onmessage = ({
data
}) => send(clientSocket, data);
}
} else if (url && url.indexOf('role=client') > -1) {
if (clientSocket) {
clientSocket.onerror = () => {};
clientSocket.onclose = () => {};
clientSocket.onmessage = () => {};
clientSocket.close(1011, 'Another client connected');
}
clientSocket = socket;
clientSocket.onerror = clientSocketCloseHandler;
clientSocket.onclose = clientSocketCloseHandler;
clientSocket.onmessage = ({
data
}) => send(debuggerSocket, data);
} else {
socket.close(1011, 'Missing role param');
}
});
return {
server: wss,
isDebuggerConnected() {
return !!debuggerSocket;
}
};
}
//# sourceMappingURL=createDebuggerProxyEndpoint.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["createDebuggerProxyEndpoint","WebSocketServer","ws","Server","wss","noServer","debuggerSocket","clientSocket","send","dest","message","e","logger","warn","debuggerSocketCloseHandler","close","clientSocketCloseHandler","JSON","stringify","method","on","socket","request","url","indexOf","onerror","onclose","onmessage","data","server","isDebuggerConnected"],"sources":["../../src/websocket/createDebuggerProxyEndpoint.ts"],"sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @format\n */\n\nimport ws from 'ws';\nimport {logger} from '@react-native-community/cli-tools';\n\nexport default function createDebuggerProxyEndpoint(): {\n server: ws.Server;\n isDebuggerConnected: () => boolean;\n} {\n const WebSocketServer = ws.Server;\n const wss = new WebSocketServer({\n noServer: true,\n });\n\n let debuggerSocket: ws | null;\n let clientSocket: ws | null;\n\n function send(dest: ws | null, message: ws.Data) {\n if (!dest) {\n return;\n }\n\n try {\n dest.send(message);\n } catch (e) {\n logger.warn(e as any);\n // Sometimes this call throws 'not opened'\n }\n }\n\n const debuggerSocketCloseHandler = () => {\n debuggerSocket = null;\n if (clientSocket) {\n clientSocket.close(1011, 'Debugger was disconnected');\n }\n };\n\n const clientSocketCloseHandler = () => {\n clientSocket = null;\n send(debuggerSocket, JSON.stringify({method: '$disconnected'}));\n };\n\n wss.on('connection', (socket, request) => {\n const {url} = request;\n\n if (url && url.indexOf('role=debugger') > -1) {\n if (debuggerSocket) {\n socket.close(1011, 'Another debugger is already connected');\n return;\n }\n debuggerSocket = socket;\n if (debuggerSocket) {\n debuggerSocket.onerror = debuggerSocketCloseHandler;\n debuggerSocket.onclose = debuggerSocketCloseHandler;\n debuggerSocket.onmessage = ({data}) => send(clientSocket, data);\n }\n } else if (url && url.indexOf('role=client') > -1) {\n if (clientSocket) {\n clientSocket.onerror = () => {};\n clientSocket.onclose = () => {};\n clientSocket.onmessage = () => {};\n clientSocket.close(1011, 'Another client connected');\n }\n clientSocket = socket;\n clientSocket.onerror = clientSocketCloseHandler;\n clientSocket.onclose = clientSocketCloseHandler;\n clientSocket.onmessage = ({data}) => send(debuggerSocket, data);\n } else {\n socket.close(1011, 'Missing role param');\n }\n });\n\n return {\n server: wss,\n isDebuggerConnected() {\n return !!debuggerSocket;\n },\n };\n}\n"],"mappings":";;;;;;AASA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAyD;AAVzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKe,SAASA,2BAA2B,GAGjD;EACA,MAAMC,eAAe,GAAGC,aAAE,CAACC,MAAM;EACjC,MAAMC,GAAG,GAAG,IAAIH,eAAe,CAAC;IAC9BI,QAAQ,EAAE;EACZ,CAAC,CAAC;EAEF,IAAIC,cAAyB;EAC7B,IAAIC,YAAuB;EAE3B,SAASC,IAAI,CAACC,IAAe,EAAEC,OAAgB,EAAE;IAC/C,IAAI,CAACD,IAAI,EAAE;MACT;IACF;IAEA,IAAI;MACFA,IAAI,CAACD,IAAI,CAACE,OAAO,CAAC;IACpB,CAAC,CAAC,OAAOC,CAAC,EAAE;MACVC,kBAAM,CAACC,IAAI,CAACF,CAAC,CAAQ;MACrB;IACF;EACF;;EAEA,MAAMG,0BAA0B,GAAG,MAAM;IACvCR,cAAc,GAAG,IAAI;IACrB,IAAIC,YAAY,EAAE;MAChBA,YAAY,CAACQ,KAAK,CAAC,IAAI,EAAE,2BAA2B,CAAC;IACvD;EACF,CAAC;EAED,MAAMC,wBAAwB,GAAG,MAAM;IACrCT,YAAY,GAAG,IAAI;IACnBC,IAAI,CAACF,cAAc,EAAEW,IAAI,CAACC,SAAS,CAAC;MAACC,MAAM,EAAE;IAAe,CAAC,CAAC,CAAC;EACjE,CAAC;EAEDf,GAAG,CAACgB,EAAE,CAAC,YAAY,EAAE,CAACC,MAAM,EAAEC,OAAO,KAAK;IACxC,MAAM;MAACC;IAAG,CAAC,GAAGD,OAAO;IAErB,IAAIC,GAAG,IAAIA,GAAG,CAACC,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE;MAC5C,IAAIlB,cAAc,EAAE;QAClBe,MAAM,CAACN,KAAK,CAAC,IAAI,EAAE,uCAAuC,CAAC;QAC3D;MACF;MACAT,cAAc,GAAGe,MAAM;MACvB,IAAIf,cAAc,EAAE;QAClBA,cAAc,CAACmB,OAAO,GAAGX,0BAA0B;QACnDR,cAAc,CAACoB,OAAO,GAAGZ,0BAA0B;QACnDR,cAAc,CAACqB,SAAS,GAAG,CAAC;UAACC;QAAI,CAAC,KAAKpB,IAAI,CAACD,YAAY,EAAEqB,IAAI,CAAC;MACjE;IACF,CAAC,MAAM,IAAIL,GAAG,IAAIA,GAAG,CAACC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE;MACjD,IAAIjB,YAAY,EAAE;QAChBA,YAAY,CAACkB,OAAO,GAAG,MAAM,CAAC,CAAC;QAC/BlB,YAAY,CAACmB,OAAO,GAAG,MAAM,CAAC,CAAC;QAC/BnB,YAAY,CAACoB,SAAS,GAAG,MAAM,CAAC,CAAC;QACjCpB,YAAY,CAACQ,KAAK,CAAC,IAAI,EAAE,0BAA0B,CAAC;MACtD;MACAR,YAAY,GAAGc,MAAM;MACrBd,YAAY,CAACkB,OAAO,GAAGT,wBAAwB;MAC/CT,YAAY,CAACmB,OAAO,GAAGV,wBAAwB;MAC/CT,YAAY,CAACoB,SAAS,GAAG,CAAC;QAACC;MAAI,CAAC,KAAKpB,IAAI,CAACF,cAAc,EAAEsB,IAAI,CAAC;IACjE,CAAC,MAAM;MACLP,MAAM,CAACN,KAAK,CAAC,IAAI,EAAE,oBAAoB,CAAC;IAC1C;EACF,CAAC,CAAC;EAEF,OAAO;IACLc,MAAM,EAAEzB,GAAG;IACX0B,mBAAmB,GAAG;MACpB,OAAO,CAAC,CAACxB,cAAc;IACzB;EACF,CAAC;AACH"}

View File

@@ -0,0 +1,10 @@
import { Server as WebSocketServer } from 'ws';
/**
* Starts the eventsSocket at the given path
*
*/
export default function createEventsSocketEndpoint(broadcast: (method: string, params?: Record<string, any>) => void): {
server: WebSocketServer;
reportEvent: (event: any) => void;
};
//# sourceMappingURL=createEventsSocketEndpoint.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createEventsSocketEndpoint.d.ts","sourceRoot":"","sources":["../../src/websocket/createEventsSocketEndpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,IAAI,eAAe,EAAC,MAAM,IAAI,CAAC;AAsG7C;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAChD,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,GAChE;IACD,MAAM,EAAE,eAAe,CAAC;IACxB,WAAW,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CACnC,CAqFA"}

View File

@@ -0,0 +1,192 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = createEventsSocketEndpoint;
function _ws() {
const data = require("ws");
_ws = function () {
return data;
};
return data;
}
function _cliTools() {
const data = require("@react-native-community/cli-tools");
_cliTools = function () {
return data;
};
return data;
}
function _prettyFormat() {
const data = _interopRequireDefault(require("pretty-format"));
_prettyFormat = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* The eventsSocket websocket listens at the 'events/` for websocket
* connections, on which all Metro reports will be emitted.
*
* This is mostly useful for developer tools (clients) that wants to monitor Metro,
* and the apps connected to Metro.
*
* The eventsSocket provides the following features:
* - it reports any Metro event (that is reported through a reporter) to all clients
* - it reports any console.log's (and friends) from the connected app to all clients
* (as client_log event)
* - it allows connected clients to send commands through Metro to the connected app.
* This reuses the generic command mechanism.
* Two useful commands are 'reload' and 'devmenu'.
*/
/**
* This number is used to version the communication protocol between
* Dev tooling like Flipper and Metro, so that in the future we can recognize
* messages coming from old clients, so that it will be simpler to implement
* backward compatibility.
*
* We start at 2 as the protocol is currently the same as used internally at FB,
* which happens to be at version 2 as well.
*/
const PROTOCOL_VERSION = 2;
function parseMessage(data) {
try {
const message = JSON.parse(data);
if (message.version === PROTOCOL_VERSION) {
return message;
}
_cliTools().logger.error('Received message had wrong protocol version: ' + message.version);
} catch {
_cliTools().logger.error('Failed to parse the message as JSON:\n' + data);
}
return undefined;
}
/**
* Two types of messages will arrive in this function,
* 1) messages generated by Metro itself (through the reporter abstraction)
* those are yet to be serialized, and can contain any kind of data structure
* 2) a specific event generated by Metro is `client_log`, which describes
* console.* calls in the app.
* The arguments send to the console are pretty printed so that they can be
* displayed in a nicer way in dev tools
*
* @param message
*/
function serializeMessage(message) {
// We do want to send Metro report messages, but their contents is not guaranteed to be serializable.
// For some known types we will pretty print otherwise not serializable parts first:
let toSerialize = message;
if (message && message.error && message.error instanceof Error) {
toSerialize = {
...message,
error: (0, _prettyFormat().default)(message.error, {
escapeString: true,
highlight: true,
maxDepth: 3,
min: true
})
};
} else if (message && message.type === 'client_log') {
toSerialize = {
...message,
data: message.data.map(item => typeof item === 'string' ? item : (0, _prettyFormat().default)(item, {
escapeString: true,
highlight: true,
maxDepth: 3,
min: true,
plugins: [_prettyFormat().default.plugins.ReactElement]
}))
};
}
try {
return JSON.stringify(toSerialize);
} catch (e) {
_cliTools().logger.error('Failed to serialize: ' + e);
return null;
}
}
/**
* Starts the eventsSocket at the given path
*
*/
function createEventsSocketEndpoint(broadcast) {
const wss = new (_ws().Server)({
noServer: true,
verifyClient({
origin
}) {
// This exposes the full JS logs and enables issuing commands like reload
// so let's make sure only locally running stuff can connect to it
// origin is only checked if it is set, e.g. when the request is made from a (CORS) browser
// any 'back-end' connection isn't CORS at all, and has full control over the origin header,
// so there is no point in checking it security wise
return !origin || origin.startsWith('http://localhost:') || origin.startsWith('file:');
}
});
const clients = new Map();
let nextClientId = 0;
/**
* broadCastEvent is called by reportEvent (below), which is called by the
* default reporter of this server, to make sure that all Metro events are
* broadcasted to all connected clients
* (that is, all devtools such as Flipper, _not_: connected apps)
*
* @param message
*/
function broadCastEvent(message) {
if (!clients.size) {
return;
}
const serialized = serializeMessage(message);
if (!serialized) {
return;
}
for (const ws of clients.values()) {
try {
ws.send(serialized);
} catch (e) {
_cliTools().logger.error(`Failed to send broadcast to client due to:\n ${e.toString()}`);
}
}
}
wss.on('connection', function (clientWs) {
const clientId = `client#${nextClientId++}`;
clients.set(clientId, clientWs);
clientWs.onclose = clientWs.onerror = () => {
clients.delete(clientId);
};
clientWs.onmessage = event => {
const message = parseMessage(event.data.toString());
if (message == null) {
return;
}
if (message.type === 'command') {
try {
/**
* messageSocket.broadcast (not to be confused with our own broadcast above)
* forwards a command to all connected React Native applications.
*/
broadcast(message.command, message.params);
} catch (e) {
_cliTools().logger.error('Failed to forward message to clients: ', e);
}
} else {
_cliTools().logger.error('Unknown message type: ', message.type);
}
};
});
return {
server: wss,
reportEvent: event => {
broadCastEvent(event);
}
};
}
//# sourceMappingURL=createEventsSocketEndpoint.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { Server as WebSocketServer } from 'ws';
export default function createMessageSocketEndpoint(): {
server: WebSocketServer;
broadcast: (method: string, params?: Record<string, any>) => void;
};
//# sourceMappingURL=createMessageSocketEndpoint.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createMessageSocketEndpoint.d.ts","sourceRoot":"","sources":["../../src/websocket/createMessageSocketEndpoint.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,MAAM,IAAI,eAAe,EAAC,MAAM,IAAI,CAAC;AA8D7C,MAAM,CAAC,OAAO,UAAU,2BAA2B,IAAI;IACrD,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;CACnE,CAiLA"}

View File

@@ -0,0 +1,207 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = createMessageSocketEndpoint;
function _url() {
const data = _interopRequireDefault(require("url"));
_url = function () {
return data;
};
return data;
}
function _ws() {
const data = require("ws");
_ws = function () {
return data;
};
return data;
}
function _cliTools() {
const data = require("@react-native-community/cli-tools");
_cliTools = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const PROTOCOL_VERSION = 2;
function parseMessage(data, binary) {
if (binary) {
_cliTools().logger.error('Expected text message, got binary!');
return undefined;
}
try {
const message = JSON.parse(data);
if (message.version === PROTOCOL_VERSION) {
return message;
}
_cliTools().logger.error(`Received message had wrong protocol version: ${message.version}`);
} catch (e) {
_cliTools().logger.error(`Failed to parse the message as JSON:\n${data}`);
}
return undefined;
}
function isBroadcast(message) {
return typeof message.method === 'string' && message.id === undefined && message.target === undefined;
}
function isRequest(message) {
return typeof message.method === 'string' && typeof message.target === 'string';
}
function isResponse(message) {
return typeof message.id === 'object' && typeof message.id.requestId !== 'undefined' && typeof message.id.clientId === 'string' && (message.result !== undefined || message.error !== undefined);
}
function createMessageSocketEndpoint() {
const wss = new (_ws().Server)({
noServer: true
});
const clients = new Map();
let nextClientId = 0;
function getClientWs(clientId) {
const clientWs = clients.get(clientId);
if (clientWs === undefined) {
throw new Error(`could not find id "${clientId}" while forwarding request`);
}
return clientWs;
}
function handleSendBroadcast(broadcasterId, message) {
const forwarded = {
version: PROTOCOL_VERSION,
method: message.method,
params: message.params
};
if (clients.size === 0) {
_cliTools().logger.warn(`No apps connected. Sending "${message.method}" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB.`);
}
for (const [otherId, otherWs] of clients) {
if (otherId !== broadcasterId) {
try {
otherWs.send(JSON.stringify(forwarded));
} catch (e) {
_cliTools().logger.error(`Failed to send broadcast to client: '${otherId}' ` + `due to:\n ${e.toString()}`);
}
}
}
}
wss.on('connection', clientWs => {
const clientId = `client#${nextClientId++}`;
function handleCaughtError(message, error) {
const errorMessage = {
id: message.id,
method: message.method,
target: message.target,
error: message.error === undefined ? 'undefined' : 'defined',
params: message.params === undefined ? 'undefined' : 'defined',
result: message.result === undefined ? 'undefined' : 'defined'
};
if (message.id === undefined) {
_cliTools().logger.error(`Handling message from ${clientId} failed with:\n${error}\n` + `message:\n${JSON.stringify(errorMessage)}`);
} else {
try {
clientWs.send(JSON.stringify({
version: PROTOCOL_VERSION,
error,
id: message.id
}));
} catch (e) {
_cliTools().logger.error(`Failed to reply to ${clientId} with error:\n${error}` + `\nmessage:\n${JSON.stringify(errorMessage)}` + `\ndue to error: ${e.toString()}`);
}
}
}
function handleServerRequest(message) {
let result = null;
switch (message.method) {
case 'getid':
result = clientId;
break;
case 'getpeers':
result = {};
clients.forEach((otherWs, otherId) => {
if (clientId !== otherId) {
result[otherId] = _url().default.parse(otherWs.upgradeReq.url, true).query;
}
});
break;
default:
throw new Error(`unknown method: ${message.method}`);
}
clientWs.send(JSON.stringify({
version: PROTOCOL_VERSION,
result,
id: message.id
}));
}
function forwardRequest(message) {
getClientWs(message.target).send(JSON.stringify({
version: PROTOCOL_VERSION,
method: message.method,
params: message.params,
id: message.id === undefined ? undefined : {
requestId: message.id,
clientId
}
}));
}
function forwardResponse(message) {
if (!message.id) {
return;
}
getClientWs(message.id.clientId).send(JSON.stringify({
version: PROTOCOL_VERSION,
result: message.result,
error: message.error,
id: message.id.requestId
}));
}
clients.set(clientId, clientWs);
const onCloseHandler = () => {
clientWs.onmessage = () => {};
clients.delete(clientId);
};
clientWs.onclose = onCloseHandler;
clientWs.onerror = onCloseHandler;
clientWs.onmessage = event => {
const message = parseMessage(event.data, event.binary);
if (message === undefined) {
_cliTools().logger.error('Received message not matching protocol');
return;
}
try {
if (isBroadcast(message)) {
handleSendBroadcast(clientId, message);
} else if (isRequest(message)) {
if (message.target === 'server') {
handleServerRequest(message);
} else {
forwardRequest(message);
}
} else if (isResponse(message)) {
forwardResponse(message);
} else {
throw new Error('Invalid message, did not match the protocol');
}
} catch (e) {
handleCaughtError(message, e.toString());
}
};
});
return {
server: wss,
broadcast: (method, params) => {
handleSendBroadcast(null, {
method,
params
});
}
};
}
//# sourceMappingURL=createMessageSocketEndpoint.ts.map

File diff suppressed because one or more lines are too long