Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discovery launch changes to check if app is actively connected or not #161

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Change Log

All notable changes to this project will be documented in this file.
## [1.0.4] - 2024-02-13

### Added

* Added ability to check if an active userid is connected or not to mock-firebolt from yaml file

### Changed

* Updated definition of ctx in files to include new function `getWebSocketConnectionForUser` that will internally return `getWsForUser` to check if an active userid is connected or not to mock-firebolt

## [1.0.3] - 2023-11-30

Expand Down
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@firebolt-js/mock-firebolt-cli",
"version": "1.0.3",
"version": "1.0.4",
"description": "Command-line interface for controlling the Mock Firebolt server",
"main": "./src/cli.mjs",
"scripts": {},
Expand Down
2 changes: 1 addition & 1 deletion conduit/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "conduit",
"description": "A TV app that works in concert with Mock Firebolt in Reverse Proxy mode",
"version": "1.0.3",
"version": "1.0.4",
"private": true,
"license": "Apache 2.0",
"author": "Mike Fine <mike_fine@cable.comcast.com>",
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@firebolt-js/mock-firebolt",
"version": "1.0.3",
"version": "1.0.4",
"description": "Controllable mock Firebolt server",
"main": "./build/index.mjs",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions server/src/events.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ function coreSendEvent(isBroadcast, ws, userId, method, result, msg, fSuccess, f
setInterval: setInterval,
set: function ss(key, val, scope) { return stateManagement.setScratch(userId, key, val, scope) },
get: function gs(key) { return stateManagement.getScratch(userId, key); },
getWebSocketConnectionForUser: function gw(userId) { return userManagement.getWsForUser(userId) },
delete: function ds(key, scope) { return stateManagement.deleteScratch(userId, key, scope)},
closeConnection: function cc() {return userManagement.closeConnection(userId, ws)},
closeAllConnections: function closeallconn() {return userManagement.closeAllConnections(userId)},
Expand Down Expand Up @@ -373,6 +374,7 @@ function coreSendEvent(isBroadcast, ws, userId, method, result, msg, fSuccess, f
setInterval: setInterval,
set: function ss(key, val, scope) { return stateManagement.setScratch(userId, key, val, scope) },
get: function gs(key) { return stateManagement.getScratch(userId, key); },
getWebSocketConnectionForUser: function gw(userId) { return userManagement.getWsForUser(userId) },
delete: function ds(key, scope) { return stateManagement.deleteScratch(userId, key, scope)},
closeConnection: function cc() {return userManagement.closeConnection(userId, ws)},
closeAllConnections: function closeallconn() {return userManagement.closeAllConnections(userId)},
Expand Down
2 changes: 2 additions & 0 deletions server/src/messageHandler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ async function handleMessage(message, userId, ws) {
setInterval: setInterval,
set: function ss(key, val, scope) { return stateManagement.setScratch(userId, key, val, scope) },
get: function gs(key) { return stateManagement.getScratch(userId, key); },
getWebSocketConnectionForUser: function gw(userId) { return userManagement.getWsForUser(userId) },
delete: function ds(key, scope) { return stateManagement.deleteScratch(userId, key, scope)},
delay: function delay(ms){ return util.delay(ms) },
closeConnection: function cc() {return userManagement.closeConnection(userId, ws)},
Expand Down Expand Up @@ -290,6 +291,7 @@ async function handleMessage(message, userId, ws) {
setInterval: setInterval,
set: function ss(key, val, scope) { return stateManagement.setScratch(userId, key, val, scope) },
get: function gs(key) { return stateManagement.getScratch(userId, key); },
getWebSocketConnectionForUser: function gw(userId) { return userManagement.getWsForUser(userId) },
delete: function ds(key, scope) { return stateManagement.deleteScratch(userId, key, scope)},
closeConnection: function cc() {return userManagement.closeConnection(userId,ws)},
closeAllConnections: function closeallconn() {return userManagement.closeAllConnections(userId)},
Expand Down
4 changes: 3 additions & 1 deletion server/src/stateManagement.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import * as commonErrors from './commonErrors.mjs';
import * as util from './util.mjs';
import { sendBroadcastEvent, sendEvent, logSuccess, logErr, logFatalErr } from './events.mjs';
import { v4 as uuidv4 } from 'uuid';
import { parseUser, closeConnection, closeAllConnections } from './userManagement.mjs';
import { parseUser, closeConnection, closeAllConnections, getWsForUser } from './userManagement.mjs';

const Mode = {
BOX: 'BOX', // Log settrs, return default defaults for each gettr based on first example within OpenRPC specification
Expand Down Expand Up @@ -242,6 +242,7 @@ async function handleDynamicResponseValues(userId, methodName, params, ws, resp)
setInterval: setInterval,
set: function ss(key, val, scope) { return setScratch(userId, key, val, scope) },
get: function gs(key) { return getScratch(userId, key); },
getWebSocketConnectionForUser: function gw(userId) { return getWsForUser(userId) },
delete: function ds(key, scope) { return deleteScratch(userId, key, scope)},
delay: function delay(ms){ return util.delay(ms) },
closeConnection: function cc() {return closeConnection(userId, ws)},
Expand Down Expand Up @@ -317,6 +318,7 @@ async function handleStaticAndDynamicResult(userId, methodName, params, resp){
const ctx = {
set: function ss(key, val, scope) { return setScratch(userId, key, val, scope) },
get: function gs(key) { return getScratch(userId, key); },
getWebSocketConnectionForUser: function gw(userId) { return getWsForUser(userId) },
delete: function ds(key, scope) { return deleteScratch(userId, key, scope)},
uuid: function cuuid() {return createUuid()},
};
Expand Down
2 changes: 2 additions & 0 deletions server/src/userManagement.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ function getWssForUser(userId) {
function getWsForUser(userId) {
if ( user2ws.has(''+userId) ) {
let wsArray=user2ws.get(''+userId);
if (wsArray && wsArray.length > 0) {
let latestWsConnection=wsArray[(wsArray.length-1)]
return latestWsConnection;
}
}
return undefined;
}

Expand Down
Loading