Skip to content

Processing - webSocketEvent is never called #24

@ankurt44

Description

@ankurt44

Hi,

I am using following code to connect to a server and send message. The server receives the messages and sends back the same message. However, the callback webSocketEvent is never called.

I do see that the server receives message from Processing client. Also, the server sends the message back because my other client (p5.js client) receives the same message. Note that server sends the message to all connected clients.

import websockets.*;

WebsocketClient wsc;

void setup() {
  size(600, 400);
  
  StringList headers = new StringList();
  headers.append("User-Agent:Processing");
  
  wsc = new WebsocketClient(this, "ws-server-url", headers);
}

void draw() {

}

void mousePressed() {
  float x = mouseX/(float)width;
  float y = mouseY/(float)height;
  
  JSONObject json = new JSONObject();
  json.setFloat("x", x);
  json.setFloat("y", y);
  wsc.sendMessage(json.toString());
  // this.webSocketEvent(json.toString());
}

void webSocketEvent(String msg){
 println(msg);
}

Could you please help me resolve this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions