Search in sources :

Example 1 with Xdag03MessageFactory

use of io.xdag.net.message.impl.Xdag03MessageFactory 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)

Aggregations

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