tyrus
  1. tyrus
  2. TYRUS-100

Chat sample broken from b74 ->b76

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Works as designed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      A simple chat sample works well on b74 but broken on b76. Chat endpoint is defined as:

      @WebSocketEndpoint(value="/websocket", configuration = DefaultServerConfiguration.class)
      public class ChatEndpoint {
          Set<Session> peers = Collections.synchronizedSet(new HashSet<Session>());
          
          @WebSocketOpen
          public void onOpen(Session peer) {
              peers.add(peer);
          }
          
          @WebSocketClose
          public void onClose(Session peer) {
              peers.remove(peer);
          }
          
          @WebSocketMessage
          public void message(String message, Session client) throws IOException, EncodeException {
              System.out.println(message);
              for (Session peer : peers) {
                  peer.getRemote().sendObject(message);
              }
          }
      }

      @WebSocketMessage is looping through all the peers but onMessage is never called across browsers. As a result Collaborative Whiteboard sample (https://blogs.oracle.com/arungupta/entry/collaborative_whiteboard_using_websocket_in) is also broken from b74 -> b76.

        Activity

        Hide
        arungupta added a comment -

        The complete chat sample is available at:

        https://blogs.oracle.com/arungupta/resource/tyrus100-chat.zip

        Show
        arungupta added a comment - The complete chat sample is available at: https://blogs.oracle.com/arungupta/resource/tyrus100-chat.zip
        Hide
        Pavel Bucek added a comment -

        change

        Set<Session> peers = Collections.synchronizedSet(new HashSet<Session>());

        to

        private static final Set<Session> peers = Collections.synchronizedSet(new HashSet<Session>());

        endpoint lifecycle change from that time (now its one instance per session - client connection).

        also, see chat sample present in Tyrus workspace, it works.

        Show
        Pavel Bucek added a comment - change Set<Session> peers = Collections.synchronizedSet( new HashSet<Session>()); to private static final Set<Session> peers = Collections.synchronizedSet( new HashSet<Session>()); endpoint lifecycle change from that time (now its one instance per session - client connection). also, see chat sample present in Tyrus workspace, it works.
        Hide
        arungupta added a comment -

        Verifying, works with b76.

        Show
        arungupta added a comment - Verifying, works with b76.

          People

          • Assignee:
            Pavel Bucek
            Reporter:
            arungupta
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: