Is anyone able to connect processing with node.js?
I get onError(EOFException: Reading WebSocket Upgrade response)
import websockets.*;
WebsocketClient wsc;
void setup() {
size(200, 200);
wsc = new WebsocketClient(this, "ws://localhost:8081");
}
void draw() {
if (mousePressed) {
wsc.sendMessage("Client message");
}
}
void webSocketEvent(String msg) {
println(msg);
}
node:
const express = require('express');
const socketIO = require('socket.io');
const http = require('http')
const port = 8081
var app = express();
let server = http.createServer(app)
var io = socketIO(server);
server.listen(port);
io.on('connection', (socket)=>{
console.log('New user connected');
// socket.emit('newMessage', {
// from:'jen@mds',
// text:'hepppp',
// createdAt:123
// });
socket.on('createMessage', (newMessage)=>{
console.log('newMessage', newMessage);
});
socket.on('disconnect', ()=>{
console.log('disconnected from user');
});
});
I think the websocket library might be dated?