xxxxxxxxxx
77
let socket = io("https://lacy-spectrum-smell.glitch.me");
function setup() {
createCanvas(window.innerWidth,window.innerHeight);
setupSockets(12000, 3334);
background(0, 0, 255);
}
function draw() {
}
function sendOsc(address, value) {
socket.emit('sendData', [address].concat(value));
}
function sendData(datatype, data) {
data.type = datatype;
socket.emit("send_data", data);
}
function setupSockets(oscPortIn, oscPortOut) {
//socket = io.connect(URL);
// socket.on("get_data", onReceiveData);
socket.on("broadcast_data", onReceiveData);
}
function onReceiveData(e){
let _cx = e.x * width;
let _cy = e.y * height;
noStroke();
ellipse(_cx,_cy,12,12);
textSize(8);
fill(255);
text(e.name,_cx+8,_cy+4);
}
function mousePressed(){
let data = {
id:socket.id,
name:socket.id,
x:mouseX/width,
y:mouseY/height
};
// console.log(socket.id);
// sendData("send_data", data);
// console.log("trysend");
socket.emit("send_data", data);
noFill();
stroke(255);
ellipse(data.x*width,data.y*height,12,12);
}