
de.saxsys.synchronizefx.nettywebsocket.CommandToWebSocketFrameCodec Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of netty-websocket-transmitter Show documentation
Show all versions of netty-websocket-transmitter Show documentation
Netty-Websocket Transmitter for SynchronizeFX
The newest version!
/**
* This file is part of SynchronizeFX.
*
* Copyright (C) 2013 Saxonia Systems AG
*
* SynchronizeFX is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SynchronizeFX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SynchronizeFX. If not, see .
*/
package de.saxsys.synchronizefx.nettywebsocket;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageCodec;
import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import io.netty.handler.codec.http.websocketx.WebSocketFrame;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.saxsys.synchronizefx.core.clientserver.Serializer;
import de.saxsys.synchronizefx.core.exceptions.SynchronizeFXException;
/**
* Encodes and decodes list of SynchronizeFX commands to web socket frames using a user supplied serializer.
*
* @author Raik Bieniek
*
*/
class CommandToWebSocketFrameCodec extends MessageToMessageCodec> {
private static final Logger LOG = LoggerFactory.getLogger(CommandToWebSocketFrameCodec.class);
private final List fragments = new LinkedList<>();
private final Serializer serializer;
/**
* Initializes the codec.
*
* @param serializer The implementation for serializing and deserializing byte[]
to SynchronizeFX
* commands.
*/
public CommandToWebSocketFrameCodec(final Serializer serializer) {
this.serializer = serializer;
}
@Override
protected void encode(final ChannelHandlerContext ctx, final List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy