Search in sources :

Example 1 with MultiSession

use of com.github.dirtpowered.dirtmv.session.MultiSession in project DirtMultiversion by DirtPowered.

the class ServerSession method broadcastPacket.

@SneakyThrows
public void broadcastPacket(PacketData packetData, MinecraftVersion from) {
    for (MultiSession entry : main.getSessionRegistry().getSessions().values()) {
        if (entry != null) {
            ServerSession serverSession = entry.getServerSession();
            if (!(serverSession.userData.getClientVersion().getRegistryId() >= from.getRegistryId())) {
                return;
            }
            serverSession.sendPacket(packetData, PacketDirection.TO_CLIENT, from);
        }
    }
}
Also used : MultiSession(com.github.dirtpowered.dirtmv.session.MultiSession) SneakyThrows(lombok.SneakyThrows)

Example 2 with MultiSession

use of com.github.dirtpowered.dirtmv.session.MultiSession in project DirtMultiversion by DirtPowered.

the class ClientSession method channelActive.

@Override
public void channelActive(ChannelHandlerContext ctx) {
    Logger.info("[{}] connected to remote server", serverSession.getLogTag());
    serverSession.getMain().getSessionRegistry().addSession(key, new MultiSession(this, serverSession));
    callback.onComplete();
}
Also used : MultiSession(com.github.dirtpowered.dirtmv.session.MultiSession)

Example 3 with MultiSession

use of com.github.dirtpowered.dirtmv.session.MultiSession in project DirtMultiversion by DirtPowered.

the class Server method getAllConnections.

@Override
public List<UserData> getAllConnections() {
    List<UserData> list = new ArrayList<>();
    for (MultiSession entry : main.getSessionRegistry().getSessions().values()) {
        UserData userData = entry.getServerSession().getUserData();
        list.add(userData);
    }
    return list;
}
Also used : UserData(com.github.dirtpowered.dirtmv.data.user.UserData) ArrayList(java.util.ArrayList) MultiSession(com.github.dirtpowered.dirtmv.session.MultiSession)

Aggregations

MultiSession (com.github.dirtpowered.dirtmv.session.MultiSession)3 UserData (com.github.dirtpowered.dirtmv.data.user.UserData)1 ArrayList (java.util.ArrayList)1 SneakyThrows (lombok.SneakyThrows)1