Error in Websockets Library

yes, did you start from

see also


test:

// https://github.com/alexandrainst/processing_websockets
// file websocket_server2.pde
// processing 3.5.3 on win7 / 64bit

import websockets.*;

WebsocketServer wss;
String outmsg="Server mouse click";

void setup() {
  size(500, 500);
  wss = new WebsocketServer(this, 8025, "/socket");
}

void draw() {
}

void mouseClicked() {  
  wss.sendMessage(outmsg);
}

void webSocketServerEvent(String msg) {
  println("event: "+msg);
}

// websockets
// https://github.com/alexandrainst/processing_websockets
// file websocket_client2.pde
// processing 3.5.3 on win7 / 64bit

import websockets.*;
String outmsg="Client mouse click";

String server = "ws://localhost:8025/socket"; 
// if i use my RPI as server: "ws://192.168.1.203:8025/socket"; // 
WebsocketClient wsc;

void setup() {
  size(500, 500);
  wsc= new WebsocketClient(this, server);
  println("pls wait for mouse click on server canvas");
}

void draw() {
}

void mouseClicked() {
  wsc.sendMessage(outmsg);
}

void webSocketEvent(String msg) {
  println("event: "+msg);
}

( means both sketch run on same computer )
then the console print works / but might be little bit confusing regarding
in what IDE window the print occurs.

1 Like