How to Create a Java API for WebSocket Text Encoder/Decoder

SampleEncoder.java

import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;

public final class SampleEncoder implements Encoder.Text<Sample> {

  @Override
  public String encode(final Sample object) {
    return null;
  }

  @Override
  public void destroy() {
  }

  @Override
  public void init(final EndpointConfig config) {
  }

}

SampleDecoder.java

import javax.websocket.Decoder;
import javax.websocket.EndpointConfig;

public final class SampleDecoder implements Decoder.Text<Sample> {

  @Override
  public Sample decode(final String s) {
    return null;
  }

  @Override
  public void destroy() {
  }

  @Override
  public void init(final EndpointConfig config) {
  }

  @Override
  public boolean willDecode(final String s) {
    return false;
  }

}

A sample is available here.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s