#OnMessage Not Being Triggered

1 messages · Page 1 of 1 (latest)

plain cobaltBOT
#

<@&987246399047479336> please have a look, thanks.

minor terrace
#
    public WebSocketConnection() {
        try {
            websocket = new WebSocketClient(new URI("ws://127.0.0.1:1226")) {

                public void onOpen(ServerHandshake handshakedata) {

                }

                public void onMessage(String message) {

                    ChatMessageUtil.sendMessage("Message Recieved!");

                    // Receive general chat messages.
                    if (message.startsWith("chatgeneral")) {
                        String json = message.replace("chatgeneral ", "");
                        if (GeneralChat.getInstance() != null) {
                            generalChat.onReceive(json);
                        }
                    }

                    // Receive version check.
                    if ( message.startsWith( "ver" ) )
                    {
                        if ( message.equals( "ver false" ) )
                            System.out.println( "HockeyLink Outdated!" );
                        else
                            System.out.println( "HockeyLink Up To Date!");
                    }
                }
plain cobaltBOT
# minor terrace ```java public WebSocketConnection() { try { websocket =...

Detected code, here are some useful tools:

Formatted code
public WebSocketConnection() {
  try {
    websocket = new WebSocketClient(new URI("ws://127.0.0.1:1226")) {
      public void onOpen(ServerHandshake handshakedata) {
      }
      public void onMessage(String message) {
        ChatMessageUtil.sendMessage("Message Recieved!");
        // Receive general chat messages.
        if (message.startsWith("chatgeneral")) {
          String json = message.replace("chatgeneral ", "");
          if (GeneralChat.getInstance() != null ) {
            generalChat.onReceive(json);
          }
        }
        // Receive version check.
        if (message.startsWith("ver")) {
          if (message.equals("ver false")) System.out.println("HockeyLink Outdated!");
          else System.out.println("HockeyLink Up To Date!");
        }
      }
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

cosmic condor
#

What library is this?

#

Consider using vert.x for web sockets 👀

cosmic condor
#

What's the error?

#

I didn't know java had an api for web sockets

subtle bluff
#

based on github, the library seems to be well updated