org.oxerr.peatio.websocket.AuthEncoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of peatio-client-websocket Show documentation
Show all versions of peatio-client-websocket Show documentation
Client for <a href="http://peat.io">Peatio</a> WebSocket API.
The newest version!
package org.oxerr.peatio.websocket;
import java.io.IOException;
import java.io.Writer;
import javax.json.Json;
import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;
import org.oxerr.peatio.websocket.dto.Auth;
public class AuthEncoder implements Encoder.TextStream {
/**
* {@inheritDoc}
*/
@Override
public void init(EndpointConfig config) {
}
/**
* {@inheritDoc}
*/
@Override
public void destroy() {
}
/**
* {@inheritDoc}
*/
@Override
public void encode(Auth auth, Writer writer) throws EncodeException,
IOException {
Json.createGenerator(writer)
.writeStartObject()
.writeStartObject("auth")
.write("access_key", auth.getAccessKey())
.write("answer", auth.getAnswer())
.writeEnd()
.writeEnd()
.flush();
}
}