closing commit before branching out Multiplex

This commit is contained in:
STEINNI
2025-10-05 10:11:03 +00:00
parent 6381bfe44a
commit 03af111d7f
16 changed files with 167 additions and 87 deletions
+11
View File
@@ -0,0 +1,11 @@
{
"channel":"agents:42",
"packet":{
"eventType": "age",
"payload": {
"aid": "agent42",
"color": "#0F0"
},
"sender": "steinic"
}
}
+1
View File
@@ -0,0 +1 @@
{"channel":"requests:gps","packet":{"action":"TIME","sender":"steinic","reqid":"9d3bcb2e-ef1d-4620-86ff-5c0b0f4063f7"}}
+4 -52
View File
@@ -1,62 +1,14 @@
{
"sequenceDelay": 500,
"sequenceLoop":10,
"sequence":[
{ {
"channel":"gps:agents", "channel":"gps:agents",
"packet":{ "packet":{
"eventType": "moving", "eventType": "move",
"payload": { "payload": {
"aid": "agent42", "aid": "agent42",
"attrs": { "coords": {
"x": "10", "x": "0",
"y": "10" "y": "0"
}
},
"sender": "steinic"
}
},
{
"channel":"gps:agents",
"packet":{
"eventType": "moving",
"payload": {
"aid": "agent42",
"attrs": {
"x": "800",
"y": "30"
}
},
"sender": "steinic"
}
},
{
"channel":"gps:agents",
"packet":{
"eventType": "moving",
"payload": {
"aid": "agent42",
"attrs": {
"x": "800",
"y": "500"
}
},
"sender": "steinic"
}
},
{
"channel":"gps:agents",
"packet":{
"eventType": "moving",
"payload": {
"aid": "agent42",
"attrs": {
"x": "10",
"y": "500"
} }
}, },
"sender": "steinic" "sender": "steinic"
} }
} }
]
}
+106
View File
@@ -0,0 +1,106 @@
{
"sequenceDelay": 500,
"sequenceLoop":10,
"sequence":[
{
"channel":"gps:agents",
"packet":{
"eventType": "move",
"payload": {
"aid": "agent42",
"coords": {
"x": "5",
"y": "5"
}
},
"sender": "steinic"
}
},
{
"channel":"gps:agents",
"packet":{
"eventType": "move",
"payload": {
"aid": "agent42",
"coords": {
"x": "-5",
"y": "5"
}
},
"sender": "steinic"
}
},
{
"channel":"gps:agents",
"packet":{
"eventType": "move",
"payload": {
"aid": "agent42",
"coords": {
"x": "-5",
"y": "-5"
}
},
"sender": "steinic"
}
},
{
"channel":"gps:agents",
"packet":{
"eventType": "move",
"payload": {
"aid": "agent42",
"coords": {
"x": "5",
"y": "-5"
}
},
"sender": "steinic"
}
},
{
"channel":"gps:agents",
"packet":{
"eventType": "move",
"payload": {
"aid": "agent42",
"coords": {
"x": "5",
"y": "5"
}
},
"sender": "steinic"
}
},
{
"channel":"gps:agents",
"packet":{
"eventType": "move",
"payload": {
"aid": "agent42",
"coords": {
"x": "5",
"y": "5",
"z": "2"
}
},
"sender": "steinic"
}
},
{
"channel":"gps:agents",
"packet":{
"eventType": "move",
"payload": {
"aid": "agent42",
"coords": {
"x": "5",
"y": "5",
"z": "0"
}
},
"sender": "steinic"
}
}
]
}
+4 -4
View File
@@ -1,12 +1,12 @@
{ {
"channel":"gps:agents", "channel":"gps:agents",
"packet":{ "packet":{
"eventType": "moving", "eventType": "move",
"payload": { "payload": {
"aid": "agent42", "aid": "agent42",
"attrs": { "coords": {
"x": "950", "x": "5",
"y": "650" "y": "5"
} }
}, },
"sender": "steinic" "sender": "steinic"
+11
View File
@@ -0,0 +1,11 @@
{
"channel":"agents:42",
"packet":{
"eventType": "polarize",
"payload": {
"aid": "agent42",
"color": "#F00"
},
"sender": "steinic"
}
}
-15
View File
@@ -199,21 +199,6 @@ module.exports = class RedisConnexion {
return(matches.length > 0); return(matches.length > 0);
} }
async getUserRoles(uid){
let roles = []
//TODO : Maybe do better...? (check in DB ?)
if(uid.startsWith('backend-')){
roles = [uid.substr(8)]
} else {
let rawPayload = await this.redisGet(uid, this.config.redis.authTokenPrefix)
let payload = JSON.parse(rawPayload)
if(payload && payload.roles) roles = payload.roles
}
if(this.debug) console.log(`Got roles for ${uid} => ${roles}`)
return(roles)
}
} }
+1 -1
View File
@@ -229,7 +229,7 @@ if(argv.file){
} else console.error('Bad file format !?', fileData) } else console.error('Bad file format !?', fileData)
} }
await rediscnx.redisClient.disconnect() await rediscnx.redisClient.disconnect()
} } else { console.error('Cannot open file !')}
} else { } else {
let dialog = new Dialog(dialogData, selectors) let dialog = new Dialog(dialogData, selectors)
dialog.start('step1').then(answers => { dialog.start('step1').then(answers => {
+1 -2
View File
@@ -7,7 +7,6 @@
"Xpass": "yj465sqfCTA0bKDw3zEYg8OqYl9Tv", "Xpass": "yj465sqfCTA0bKDw3zEYg8OqYl9Tv",
"user": "", "user": "",
"pass": "", "pass": "",
"basePrefix": "messageBus:", "basePrefix": "messageBus:"
"authTokenPrefix": "authorizer:message_bus_user_"
} }
} }
+13
View File
@@ -0,0 +1,13 @@
{
"channel":"agents:42",
"packet":{
"eventType": "rotate",
"payload": {
"aid": "agent42",
"facing": {
"y": "45"
}
},
"sender": "steinic"
}
}
+4 -1
View File
@@ -19,7 +19,10 @@ export const methods = {
for(var chan of payload){ for(var chan of payload){
if((!chan) || (typeof(chan)!='string')) continue if((!chan) || (typeof(chan)!='string')) continue
if(!this.accessRights.canSubscribe(this.userId, this.roles, chan)) continue if(!this.accessRights.canSubscribe(this.userId, this.roles, chan)) {
if(this.debug) console.log('SUB: No rights to this chan!', this.userId, this.roles, chan)
continue
}
// Chat chans are forbidden here // Chat chans are forbidden here
if((chan.substr(0,8) == 'userchans') || (chan.substr(0,9) == 'lobbychans')) continue; if((chan.substr(0,8) == 'userchans') || (chan.substr(0,9) == 'lobbychans')) continue;
-2
View File
@@ -74,7 +74,6 @@
"port": { "type": "integer" }, "port": { "type": "integer" },
"user": { "type": "string" }, "user": { "type": "string" },
"pass": { "type": "string" }, "pass": { "type": "string" },
"authTokenPrefix": { "type": "string" },
"basePrefix": { "type": "string" }, "basePrefix": { "type": "string" },
"challengePrefix": { "type": "string" }, "challengePrefix": { "type": "string" },
"historizeMax": { "type": "integer" }, "historizeMax": { "type": "integer" },
@@ -90,7 +89,6 @@
} }
}, },
"required": [ "required": [
"authTokenPrefix",
"basePrefix", "basePrefix",
"challengePrefix", "challengePrefix",
"historizeChannels", "historizeChannels",
View File
+1
View File
@@ -238,6 +238,7 @@ export class RedisConnexion {
} }
} }
console.log('=====>',uuids)
for(var uuid of uuids) { for(var uuid of uuids) {
if(uuid in this.wssConnections) { if(uuid in this.wssConnections) {
if(this.debug) console.log('Sending to ', uuid, payload); if(this.debug) console.log('Sending to ', uuid, payload);
+3 -3
View File
@@ -1,11 +1,11 @@
#!/bin/sh #!/bin/sh
cd /opt/WssGateway/ cd /opt/p42wssGateway/
pid=`ps -ef | grep wssGateway |grep -v grep | awk '{print $2}'` pid=`ps -ef | grep p42wssGateway |grep -v grep | awk '{print $2}'`
if [ -z "$pid" ] if [ -z "$pid" ]
then then
node wssGateway.js > wssGateway.log 2>&1 & node p42wssGateway.js > wssGateway.log 2>&1 &
else else
echo '' echo ''
echo 'Already running PID='"$pid"' (use stopWssGw.sh to stop it)' echo 'Already running PID='"$pid"' (use stopWssGw.sh to stop it)'
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
pid=`ps -ef | grep wssGateway.js |grep -v grep | awk '{print $2}'` pid=`ps -ef | grep p42wssGateway.js |grep -v grep | awk '{print $2}'`
if [ -n "$pid" ] if [ -n "$pid" ]
then then
echo "killing pid: $pid" echo "killing pid: $pid"