Search in sources :

Example 6 with Packet

use of io.discloader.discloader.entity.sendable.Packet in project DiscLoader by R3alCl0ud.

the class GatewayListener method sendResume.

public void sendResume() {
    if (tries >= 3) {
        sendNewIdentify();
        return;
    }
    Packet d = new Packet(OPCodes.RESUME, new GatewayResume(socket.sessionID, token, socket.s));
    socket.send(d, true);
}
Also used : Packet(io.discloader.discloader.entity.sendable.Packet) GatewayResume(io.discloader.discloader.network.gateway.packets.request.GatewayResume)

Example 7 with Packet

use of io.discloader.discloader.entity.sendable.Packet in project DiscLoader by R3alCl0ud.

the class GatewayListener method sendNewIdentify.

public void sendNewIdentify() {
    if (!loader.token.startsWith("Bot ")) {
        token = loader.token;
    }
    System.out.println(token);
    GatewayIdentify payload = new GatewayIdentify(token, 250, new Properties("DiscLoader", "DiscLoader", "DiscLoader"));
    try {
        if (this.loader.shards > 1) {
            payload.setShard(loader.shardid, loader.shards);
        }
    } catch (NullPointerException e) {
        logger.throwing(e.getStackTrace()[0].getClassName(), e.getStackTrace()[0].getMethodName(), e);
    }
    Packet packet = new Packet(OPCodes.IDENTIFY, payload);
    socket.send(packet, true);
    socket.s = -1;
    tries = 0;
}
Also used : Packet(io.discloader.discloader.entity.sendable.Packet) GatewayIdentify(io.discloader.discloader.network.gateway.packets.request.GatewayIdentify) Properties(io.discloader.discloader.network.gateway.packets.request.Properties)

Example 8 with Packet

use of io.discloader.discloader.entity.sendable.Packet in project DiscLoader by R3alCl0ud.

the class DiscLoader method syncGuilds.

/**
 * Syncs guilds to client if the logged in user is not a bot
 *
 * @param guildIDs
 *            the ids of the guilds to sync
 * @throws AccountTypeException
 * @throws GuildSyncException
 */
public void syncGuilds(long... guildIDs) throws AccountTypeException, GuildSyncException {
    if (user.isBot())
        throw new AccountTypeException("Only user accounts are allowed to sync guilds");
    String[] ids = new String[guildIDs.length];
    for (int i = 0; i < guildIDs.length; i++) {
        ids[i] = Long.toUnsignedString(guildIDs[i], 10);
    }
    Packet packet = new Packet(12, ids);
    socket.send(packet, true);
}
Also used : Packet(io.discloader.discloader.entity.sendable.Packet) AccountTypeException(io.discloader.discloader.common.exceptions.AccountTypeException)

Example 9 with Packet

use of io.discloader.discloader.entity.sendable.Packet in project DiscLoader by R3alCl0ud.

the class DiscLoader method syncGuilds.

/**
 * Syncs guilds to client if the logged in user is not a bot
 *
 * @param guildIDs
 *            the ids of the guilds to sync
 * @throws AccountTypeException
 * @throws GuildSyncException
 */
public void syncGuilds(String... guildIDs) throws AccountTypeException, GuildSyncException {
    if (user.isBot())
        throw new AccountTypeException("Only user accounts are allowed to sync guilds");
    for (String id : guildIDs) {
        if (isGuildSyncing(id))
            throw new GuildSyncException("Cannot syncing a guild that is currently syncing");
    }
    Packet packet = new Packet(12, guildIDs);
    socket.send(packet, true);
}
Also used : Packet(io.discloader.discloader.entity.sendable.Packet) AccountTypeException(io.discloader.discloader.common.exceptions.AccountTypeException) GuildSyncException(io.discloader.discloader.common.exceptions.GuildSyncException)

Aggregations

Packet (io.discloader.discloader.entity.sendable.Packet)9 AccountTypeException (io.discloader.discloader.common.exceptions.AccountTypeException)3 GuildSyncException (io.discloader.discloader.common.exceptions.GuildSyncException)2 VoiceStateUpdate (io.discloader.discloader.entity.sendable.VoiceStateUpdate)2 GuildMembersChunkEvent (io.discloader.discloader.common.event.guild.member.GuildMembersChunkEvent)1 GatewayIdentify (io.discloader.discloader.network.gateway.packets.request.GatewayIdentify)1 GatewayResume (io.discloader.discloader.network.gateway.packets.request.GatewayResume)1 Properties (io.discloader.discloader.network.gateway.packets.request.Properties)1 StatusUpdate (io.discloader.discloader.network.gateway.packets.request.StatusUpdate)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Consumer (java.util.function.Consumer)1 JSONObject (org.json.JSONObject)1