Search in sources :

Example 1 with XdagBlockHandler

use of io.xdag.net.handler.XdagBlockHandler in project xdagj by XDagger.

the class Libp2pXdagProtocol method initChannel.

@NotNull
@Override
public CompletableFuture<Libp2pXdagController> initChannel(@NotNull P2PChannel p2PChannel, @NotNull String s) {
    final Connection connection = ((io.libp2p.core.Stream) p2PChannel).getConnection();
    libp2pChannel = new Libp2pChannel(connection, this, kernel);
    channelManager.add(libp2pChannel);
    blockHandler = new XdagBlockHandler(libp2pChannel);
    blockHandler.setMessageFactory(new Xdag03MessageFactory());
    channelManager.onChannelActive(libp2pChannel, libp2pChannel.getNode());
    MessageCodes messageCodes = new MessageCodes();
    libp2PXdagController = new Libp2pXdagController(kernel, libp2pChannel);
    // add handler
    p2PChannel.pushHandler(blockHandler);
    p2PChannel.pushHandler(messageCodes);
    p2PChannel.pushHandler(libp2PXdagController);
    return libp2PXdagController.activeFuture;
}
Also used : Connection(io.libp2p.core.Connection) MessageCodes(io.xdag.net.handler.MessageCodes) XdagBlockHandler(io.xdag.net.handler.XdagBlockHandler) Xdag03MessageFactory(io.xdag.net.message.impl.Xdag03MessageFactory) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with XdagBlockHandler

use of io.xdag.net.handler.XdagBlockHandler in project xdagj by XDagger.

the class XdagChannel method init.

public void init(ChannelPipeline pipeline, Kernel kernel, boolean isServer, InetSocketAddress inetSocketAddress) {
    this.kernel = kernel;
    this.inetSocketAddress = inetSocketAddress;
    this.handshakeHandler = new XdagHandshakeHandler(kernel, this);
    handshakeHandler.setServer(isServer);
    pipeline.addLast("handshakeHandler", handshakeHandler);
    this.messageQueue = new MessageQueue(this);
    this.messageCodec = new MessageCodes();
    this.blockHandler = new XdagBlockHandler(this);
    this.xdagHandlerFactory = new XdagHandlerFactoryImpl(kernel, this);
}
Also used : XdagHandlerFactoryImpl(io.xdag.net.handler.XdagHandlerFactoryImpl) MessageQueue(io.xdag.net.message.MessageQueue) XdagHandshakeHandler(io.xdag.net.handler.XdagHandshakeHandler) MessageCodes(io.xdag.net.handler.MessageCodes) XdagBlockHandler(io.xdag.net.handler.XdagBlockHandler)

Aggregations

MessageCodes (io.xdag.net.handler.MessageCodes)2 XdagBlockHandler (io.xdag.net.handler.XdagBlockHandler)2 Connection (io.libp2p.core.Connection)1 XdagHandlerFactoryImpl (io.xdag.net.handler.XdagHandlerFactoryImpl)1 XdagHandshakeHandler (io.xdag.net.handler.XdagHandshakeHandler)1 MessageQueue (io.xdag.net.message.MessageQueue)1 Xdag03MessageFactory (io.xdag.net.message.impl.Xdag03MessageFactory)1 NotNull (org.jetbrains.annotations.NotNull)1