diff --git a/Rabbit-injector/age_aget42.bmsg b/Rabbit-injector/age_aget42.bmsg new file mode 100644 index 0000000..77e586c --- /dev/null +++ b/Rabbit-injector/age_aget42.bmsg @@ -0,0 +1,11 @@ +{ + "channel":"agents:42", + "packet":{ + "eventType": "age", + "payload": { + "aid": "agent42", + "color": "#0F0" + }, + "sender": "steinic" + } +} diff --git a/Rabbit-injector/gps-time.bmsg b/Rabbit-injector/gps-time.bmsg new file mode 100644 index 0000000..8ebac91 --- /dev/null +++ b/Rabbit-injector/gps-time.bmsg @@ -0,0 +1 @@ +{"channel":"requests:gps","packet":{"action":"TIME","sender":"steinic","reqid":"9d3bcb2e-ef1d-4620-86ff-5c0b0f4063f7"}} diff --git a/Rabbit-injector/move_aget42-2.bmsg b/Rabbit-injector/move_aget42-2.bmsg index 3b79baa..4bd70ad 100644 --- a/Rabbit-injector/move_aget42-2.bmsg +++ b/Rabbit-injector/move_aget42-2.bmsg @@ -1,62 +1,14 @@ { - "sequenceDelay": 500, - "sequenceLoop":10, - "sequence":[ - { - "channel":"gps:agents", - "packet":{ - "eventType": "moving", - "payload": { - "aid": "agent42", - "attrs": { - "x": "10", - "y": "10" - } - }, - "sender": "steinic" + "channel":"gps:agents", + "packet":{ + "eventType": "move", + "payload": { + "aid": "agent42", + "coords": { + "x": "0", + "y": "0" } }, - { - "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" + } } diff --git a/Rabbit-injector/move_aget42-cont.bmsg b/Rabbit-injector/move_aget42-cont.bmsg new file mode 100644 index 0000000..8da59e3 --- /dev/null +++ b/Rabbit-injector/move_aget42-cont.bmsg @@ -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" + } + } + ] +} diff --git a/Rabbit-injector/move_aget42.bmsg b/Rabbit-injector/move_aget42.bmsg index 652ba4c..9325a23 100644 --- a/Rabbit-injector/move_aget42.bmsg +++ b/Rabbit-injector/move_aget42.bmsg @@ -1,12 +1,12 @@ { "channel":"gps:agents", "packet":{ - "eventType": "moving", + "eventType": "move", "payload": { "aid": "agent42", - "attrs": { - "x": "950", - "y": "650" + "coords": { + "x": "5", + "y": "5" } }, "sender": "steinic" diff --git a/Rabbit-injector/polarize_aget42.bmsg b/Rabbit-injector/polarize_aget42.bmsg new file mode 100644 index 0000000..774439e --- /dev/null +++ b/Rabbit-injector/polarize_aget42.bmsg @@ -0,0 +1,11 @@ +{ + "channel":"agents:42", + "packet":{ + "eventType": "polarize", + "payload": { + "aid": "agent42", + "color": "#F00" + }, + "sender": "steinic" + } +} diff --git a/Rabbit-injector/redisConnexion.js b/Rabbit-injector/redisConnexion.js index 807f2ed..1c9563e 100644 --- a/Rabbit-injector/redisConnexion.js +++ b/Rabbit-injector/redisConnexion.js @@ -199,21 +199,6 @@ module.exports = class RedisConnexion { 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) - } - } diff --git a/Rabbit-injector/ri.js b/Rabbit-injector/ri.js index 1ebe1cf..6f5ab8c 100644 --- a/Rabbit-injector/ri.js +++ b/Rabbit-injector/ri.js @@ -229,7 +229,7 @@ if(argv.file){ } else console.error('Bad file format !?', fileData) } await rediscnx.redisClient.disconnect() - } + } else { console.error('Cannot open file !')} } else { let dialog = new Dialog(dialogData, selectors) dialog.start('step1').then(answers => { diff --git a/Rabbit-injector/riConfig.json b/Rabbit-injector/riConfig.json index 958a692..db866a5 100644 --- a/Rabbit-injector/riConfig.json +++ b/Rabbit-injector/riConfig.json @@ -7,7 +7,6 @@ "Xpass": "yj465sqfCTA0bKDw3zEYg8OqYl9Tv", "user": "", "pass": "", - "basePrefix": "messageBus:", - "authTokenPrefix": "authorizer:message_bus_user_" + "basePrefix": "messageBus:" } } diff --git a/Rabbit-injector/rotate_aget42.bmsg b/Rabbit-injector/rotate_aget42.bmsg new file mode 100644 index 0000000..c2d2f2d --- /dev/null +++ b/Rabbit-injector/rotate_aget42.bmsg @@ -0,0 +1,13 @@ +{ + "channel":"agents:42", + "packet":{ + "eventType": "rotate", + "payload": { + "aid": "agent42", + "facing": { + "y": "45" + } + }, + "sender": "steinic" + } +} diff --git a/actions/pubSub.js b/actions/pubSub.js index c4b8185..ee4bc4c 100644 --- a/actions/pubSub.js +++ b/actions/pubSub.js @@ -19,7 +19,10 @@ export const methods = { for(var chan of payload){ 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 if((chan.substr(0,8) == 'userchans') || (chan.substr(0,9) == 'lobbychans')) continue; diff --git a/configSchema.json b/configSchema.json index c8d866e..ca9f169 100644 --- a/configSchema.json +++ b/configSchema.json @@ -74,7 +74,6 @@ "port": { "type": "integer" }, "user": { "type": "string" }, "pass": { "type": "string" }, - "authTokenPrefix": { "type": "string" }, "basePrefix": { "type": "string" }, "challengePrefix": { "type": "string" }, "historizeMax": { "type": "integer" }, @@ -90,7 +89,6 @@ } }, "required": [ - "authTokenPrefix", "basePrefix", "challengePrefix", "historizeChannels", diff --git a/wssGateway.js b/p42wssGateway.js similarity index 100% rename from wssGateway.js rename to p42wssGateway.js diff --git a/redisConnexion.js b/redisConnexion.js index 2e474b4..451e4b8 100644 --- a/redisConnexion.js +++ b/redisConnexion.js @@ -238,6 +238,7 @@ export class RedisConnexion { } } + console.log('=====>',uuids) for(var uuid of uuids) { if(uuid in this.wssConnections) { if(this.debug) console.log('Sending to ', uuid, payload); diff --git a/startWssGw.sh b/startWssGw.sh index 1d92a25..79d9158 100755 --- a/startWssGw.sh +++ b/startWssGw.sh @@ -1,11 +1,11 @@ #!/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" ] then - node wssGateway.js > wssGateway.log 2>&1 & + node p42wssGateway.js > wssGateway.log 2>&1 & else echo '' echo 'Already running PID='"$pid"' (use stopWssGw.sh to stop it)' diff --git a/stopWssGw.sh b/stopWssGw.sh index 25c9622..0f03774 100755 --- a/stopWssGw.sh +++ b/stopWssGw.sh @@ -1,6 +1,6 @@ #!/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" ] then echo "killing pid: $pid"