Error in Websockets Library

I am getting the following error when I run the example code for a websocket server.

"The constructor “WebsocketServer(WebsocketServer, int, String)” does not exist".

The relevant code is as follows:


import websockets.*;

WebsocketServer ws;
int now;
float x,y;

void setup(){
  size(200,200);
  ws= new WebsocketServer(this,8080,"");
  now=millis();
  x=0;
  y=0;
}
1 Like

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

Thank you for the reply. I found the solution. For some reason the program does not work if you copy/paste the example code from github. But, if I run it directly from the examples folder it works fine.