websocket-spec
  1. websocket-spec
  2. WEBSOCKET_SPEC-198

Add the ability to define global encoders and decoders

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      In a future version of the WebSocket API, I would love to see the ability to specify global encoders and decoders both of the client and server side. This could be very similar to how you can specify JAX-RS 2 providers today (e.g. to globally handle JSON encoding/decoding with a generic tool).

      Do let me know if anything needs to be explained further - I am happy to help.

      Please note that these are purely my personal views and certainly not of Oracle's as a company.

        Activity

        Hide
        Nick Williams added a comment -

        We could add a new annotation, @WebSocketCodecs, that can be applied to types used as WebSocket messages. For example:

        @WebSocketCodecs(
                encoders = { MyEncoderText.class, MyEncoderBinary.class },
                decoders = { MyDecoderText.class, MyDecoderBinary.class }
        )
        public class MyMessageObject
        {
            ...
        }
        

        The encoders and decoders attributes must have at least one and may have at most four values: a text encoder/decoder, a binary encoder/decoder, a text stream encoder/decoder, and a binary stream encoder/decoder.

        Show
        Nick Williams added a comment - We could add a new annotation, @WebSocketCodecs , that can be applied to types used as WebSocket messages. For example: @WebSocketCodecs( encoders = { MyEncoderText.class, MyEncoderBinary.class }, decoders = { MyDecoderText.class, MyDecoderBinary.class } ) public class MyMessageObject { ... } The encoders and decoders attributes must have at least one and may have at most four values: a text encoder/decoder, a binary encoder/decoder, a text stream encoder/decoder, and a binary stream encoder/decoder.

          People

          • Assignee:
            Unassigned
            Reporter:
            reza_rahman
          • Votes:
            7 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: