Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. import pro.beam.api.BeamAPI;
  2. import pro.beam.api.resource.BeamUser;
  3. import pro.beam.api.resource.channel.BeamChannel;
  4. import pro.beam.api.resource.chat.BeamChat;
  5. import pro.beam.api.resource.chat.methods.AuthenticateMessage;
  6. import pro.beam.api.resource.chat.methods.ChatSendMethod;
  7. import pro.beam.api.resource.chat.replies.AuthenticationReply;
  8. import pro.beam.api.resource.chat.replies.ReplyHandler;
  9. import pro.beam.api.resource.chat.ws.BeamChatConnectable;
  10. import pro.beam.api.services.impl.ChatService;
  11. import pro.beam.api.services.impl.UsersService;
  12.  
  13. import java.util.concurrent.ExecutionException;
  14.  
  15. public class Main {
  16.  
  17.  
  18. public static void main(String[] args) throws ExecutionException, InterruptedException {
  19. String username = "";
  20. String password = "";
  21. BeamAPI beam = new BeamAPI();
  22. BeamUser user = beam.use(UsersService.class).login(username,password).get();
  23. BeamChannel channel = user.channel;
  24. BeamChat chat = beam.use(ChatService.class).findOne(channel.id).get();
  25. BeamChatConnectable chatConnectable = chat.connectable(beam);
  26. if (chatConnectable.connect()) {
  27. chatConnectable.send(AuthenticateMessage.from(channel, user, chat.authkey), new ReplyHandler<AuthenticationReply>() {
  28. public void onSuccess(AuthenticationReply reply) {
  29. chatConnectable.send(ChatSendMethod.of("Hello World"));
  30. }
  31. public void onFailure(Throwable var1) {
  32. var1.printStackTrace();
  33. }
  34. });
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement