Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pro.beam.api.BeamAPI;
- import pro.beam.api.resource.BeamUser;
- import pro.beam.api.resource.channel.BeamChannel;
- import pro.beam.api.resource.chat.BeamChat;
- import pro.beam.api.resource.chat.methods.AuthenticateMessage;
- import pro.beam.api.resource.chat.methods.ChatSendMethod;
- import pro.beam.api.resource.chat.replies.AuthenticationReply;
- import pro.beam.api.resource.chat.replies.ReplyHandler;
- import pro.beam.api.resource.chat.ws.BeamChatConnectable;
- import pro.beam.api.services.impl.ChatService;
- import pro.beam.api.services.impl.UsersService;
- import java.util.concurrent.ExecutionException;
- public class Main {
- public static void main(String[] args) throws ExecutionException, InterruptedException {
- String username = "";
- String password = "";
- BeamAPI beam = new BeamAPI();
- BeamUser user = beam.use(UsersService.class).login(username,password).get();
- BeamChannel channel = user.channel;
- BeamChat chat = beam.use(ChatService.class).findOne(channel.id).get();
- BeamChatConnectable chatConnectable = chat.connectable(beam);
- if (chatConnectable.connect()) {
- chatConnectable.send(AuthenticateMessage.from(channel, user, chat.authkey), new ReplyHandler<AuthenticationReply>() {
- public void onSuccess(AuthenticationReply reply) {
- chatConnectable.send(ChatSendMethod.of("Hello World"));
- }
- public void onFailure(Throwable var1) {
- var1.printStackTrace();
- }
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement