Hello again,
i`m having dificulties with the code again. So i better just say what i`m trying to do.
The idea is to make a RC car race game over wi-fi. (Think Mario Kart or Rock `n Roll Racing with real cars.). I got the idea from this guy:
so i`m using:
The same PC will be a client with a browser and a gamepad. (i`m thinking that it can go up to 10 clients if it works)
each client will send gamepad commands through the browser to a car hooked with a raspberry pi and a camera.
i`m thinking the setup would be:
the "server" is a javascript frontend so i can monitor the changes in the race in real time and broadcast the info like lap times, positions, and who shot who
the "car" will have a python backend (mostly receiving the gamepad and send a message to the server when it makes a lap)
and the "pilot" a javascript frontend (with a gamepad to send commands to his car and receive updates from server)
so i made a realm "race" then there will be topics like "pilot1 to 10" and "car1 to 10" and "server".
the questions are:
1. Is what i`m thinking correct ? :)
2. i`m unsure, wich is best to use, PubSub or RPC to run python commands on the Raspberry Pi ? (from what i read looks like RPC is better)
3. is there already a standard way to know wich clients are subscribed to wich topic ? i`m asking this because i must know what cars are online, what pilots are connected to wich cars. (it can be set to a default, but the server must know)
4. in the PubSub model i didnt find a way to broadcast the info. Do i have to send a message to each topic ?
my current problems are:
1. migrating the example code you provided for the gamepad from the monitor.js to python, since that`s the only thing the raspberry pi will be needing.
i`m still messing with both, the votes example as suggested by Alexander, and the basic pubsub but its hard since the codes seem different on each one.
2. breaking down the array that the gamepad is sending. how is that formatted ?
any help will be greatly apreciated.
Thanks again