websocket-spec
  1. websocket-spec
  2. WEBSOCKET_SPEC-4

Ambiguous: Can multiple POJO methods be mapped to the same URI ?

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      @WebSocketEndpoint("/hello")
      public class HelloServer {
      @WebSocketMessage
      public void processGreeting(String message)

      { .. }

      @WebSocketMessage
      public void processCommunication(String message) { .. }

      }

      both get called ? What order ? Sequentially on same thread ?

      Can a POJO annotate multiple methods with the same annotation more than once, for the other annotations too @WebSocketOpen and so on ?

        Activity

        Hide
        dannycoward added a comment -

        Current thoughts: We can't have multiple methods handling same message, otherwise the implementation would need to copy messages, which may be very large.

        You might think this would make some sense:-

        @WebSocketEndpoint("/hello", decoders=

        {MyAppleDecoder.class}

        )
        public class HelloServer {
        @WebSocketMessage
        public void processGreeting(String message)

        { .. }

        @WebSocketMessage
        public void processCommunication(Apple apple) { .. }

        }

        but again, the message would be consumed twice. Currently I am thinking that the onMessage and @WebSocketMessage methods consume the message, so there can only be one.

        If we made such a restriction, we would need to enforce it (at deployment time). It wouldn't be very nice to try to pick which method actually won.

        Show
        dannycoward added a comment - Current thoughts: We can't have multiple methods handling same message, otherwise the implementation would need to copy messages, which may be very large. You might think this would make some sense:- @WebSocketEndpoint("/hello", decoders= {MyAppleDecoder.class} ) public class HelloServer { @WebSocketMessage public void processGreeting(String message) { .. } @WebSocketMessage public void processCommunication(Apple apple) { .. } } but again, the message would be consumed twice. Currently I am thinking that the onMessage and @WebSocketMessage methods consume the message, so there can only be one. If we made such a restriction, we would need to enforce it (at deployment time). It wouldn't be very nice to try to pick which method actually won.
        Hide
        dannycoward added a comment -

        We will restrict the model to being able to configure only one MessageHandler per native websocket message type: text, binary and Pong.

        Show
        dannycoward added a comment - We will restrict the model to being able to configure only one MessageHandler per native websocket message type: text, binary and Pong.

          People

          • Assignee:
            dannycoward
            Reporter:
            dannycoward
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Due:
              Created:
              Updated:
              Resolved: