Search in sources :

Example 1 with Message

use of io.discloader.discloader.core.entity.message.Message in project DiscLoader by R3alCl0ud.

the class FetchMessages method complete.

@Override
public void complete(String s, Throwable ex) {
    if (ex != null) {
        future.completeExceptionally(ex);
        return;
    } else {
        MessageJSON[] data = DLUtil.gson.fromJson(s, MessageJSON[].class);
        HashMap<Long, IMessage> messages = new HashMap<>();
        for (MessageJSON m : data) {
            IMessage message = new Message<>(channel, m);
            channel.getMessages().put(message.getID(), message);
            messages.put(message.getID(), message);
        }
        future.complete(messages);
    }
}
Also used : IMessage(io.discloader.discloader.entity.message.IMessage) Message(io.discloader.discloader.core.entity.message.Message) MessageJSON(io.discloader.discloader.network.json.MessageJSON) HashMap(java.util.HashMap) IMessage(io.discloader.discloader.entity.message.IMessage)

Example 2 with Message

use of io.discloader.discloader.core.entity.message.Message in project DiscLoader by R3alCl0ud.

the class PinnedMessages method complete.

@Override
public void complete(String s, Throwable ex) {
    if (ex != null) {
        future.completeExceptionally(ex);
        return;
    } else {
        MessageJSON[] data = DLUtil.gson.fromJson(s, MessageJSON[].class);
        HashMap<Long, IMessage> messages = new HashMap<>();
        for (MessageJSON m : data) {
            IMessage message = new Message<T>(channel, m);
            channel.getMessages().put(message.getID(), message);
            messages.put(message.getID(), message);
        }
        future.complete(messages);
    }
}
Also used : IMessage(io.discloader.discloader.entity.message.IMessage) Message(io.discloader.discloader.core.entity.message.Message) MessageJSON(io.discloader.discloader.network.json.MessageJSON) HashMap(java.util.HashMap) IMessage(io.discloader.discloader.entity.message.IMessage)

Example 3 with Message

use of io.discloader.discloader.core.entity.message.Message in project DiscLoader by R3alCl0ud.

the class FetchMessage method complete.

@Override
public void complete(String s, Throwable ex) {
    if (ex != null) {
        future.completeExceptionally(ex);
        return;
    }
    MessageJSON data = DLUtil.gson.fromJson(s, MessageJSON.class);
    IMessage message = new Message<>(channel, data);
    channel.getMessages().put(message.getID(), message);
    future.complete(message);
}
Also used : IMessage(io.discloader.discloader.entity.message.IMessage) Message(io.discloader.discloader.core.entity.message.Message) MessageJSON(io.discloader.discloader.network.json.MessageJSON) IMessage(io.discloader.discloader.entity.message.IMessage)

Aggregations

Message (io.discloader.discloader.core.entity.message.Message)3 IMessage (io.discloader.discloader.entity.message.IMessage)3 MessageJSON (io.discloader.discloader.network.json.MessageJSON)3 HashMap (java.util.HashMap)2