I feel I am pretty competent with Processing (java) but have no experience with servers and the like. What would be the best/easiest way to implement a “server/broker” that could allow multiple instances of a sketch simultaneously running in various locations around the country to have a synchronized high score list?
I know there are lots of way to accomplish this but the only one that I can think of would be to use the network library, link the client machines through a VPN like ZeroTierOne, and run a separate server sketch that can parse and compare the incoming scores. I have not tested it but it sounds doable. Thinking 100 clients max.
Thanks!
I’m writing a drawing application in Processing and connect instances to a central server running a PHP/SQLite database using the contributed library, HTTP Requests for Processing. It’s pretty simple to send POST or GET (html form or query string style) data from Processing. PHP is what I chose but it could be Python, Perl, or even Java. Most web hosting platforms can handle a multitude of languages.
Socken.io is a library and protocol based an WebSocket (only for the first connect) but is faster
simple Server example server.js :
var express = require(“express”);
// express app instance
var app = express();
// server
var server = app.listen(3000);
// static files
app.use(express.static(“public”));
// socket.io instance
var socket = require(“socket.io”);
var io = socket(server);
// new connection event
io.sockets.on(“connection”, newConnection);
function newConnection(socket) {
console.log(“new connection” + socket.id);
console.log(socket.id);
// mouse event listener
socket.on(“mouse”, mouseMsg);
function mouseMsg(data) {
// broadcast to all clients
socket.broadcast.emit(“mouse”, data);
console.log(data);
}
}