Use web socket to transfer a String

Hey guys, I was trying to transfer a String from Node server to processing, the data do come in but when I do the conditional check, the msg == “8” returns false? Can anyone help me with this? Is there a datatype difference between java and js?

JS Code:

input.addEventListener("keydown",(event) =>{
        if(event.which == 8){

In Processing:

//this will be executed whenever the server send a message;
void webSocketEvent(String msg){
  println(msg); // print 8;
  println(msg == "8"); //return false!!!
  if(msg == "8"){
    audienceTweet = audienceTweet.substring(0,audienceTweet.length()-1);
    audienceTweet = audienceTweet + msg;
1 Like

might be that there is a different string as you think

also string comparison must use not ==

unless it is a character? then must use == '8'
not .equals("8") or == "8"

1 Like

oops, I just figured it out, thanks; I used Js string comparison in java…

1 Like