com.quotemedia.streamer.client.impl.QitchEncoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of streamerclient-java-core Show documentation
Show all versions of streamerclient-java-core Show documentation
Java streaming client that provides easy-to-use client APIs to connect and subscribe to QuoteMedia's market data streaming services. https://quotemedia.com/
The newest version!
package com.quotemedia.streamer.client.impl;
import com.quotemedia.qitch.BlockEncoder;
import com.quotemedia.streamer.messages.smessage.SMessage;
import org.atmosphere.wasync.Encoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.checkNotNull;
public class QitchEncoder implements Encoder {
private static final Logger log = LoggerFactory.getLogger(QitchEncoder.class);
private final BlockEncoder encoder;
public QitchEncoder(final BlockEncoder encoder) {
this.encoder = checkNotNull(encoder);
}
@Override
public byte[] encode(final SMessage msg) {
try {
if (msg instanceof MessageImpl) {
return this.encoder.encode(msg.sequencenumber(), 0, ((MessageImpl) msg).decodedpayload());
} else if (msg != null) {
log.warn("Unsupported SMessage implementation {}", msg.getClass().getName());
}
return null;
} catch (final Exception e) {
log.warn("Problem encoding message. Reason {}: {}", e.getClass().getSimpleName(), e.getMessage());
log.debug("Problem encoding message.", e);
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy