SHARE
TWEET

Untitled

Jampire Mar 20th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                 switch (json.get("type").getAsString()) {
  2.                     case "@WS/USER/SET_STATUS":
  3.                         App.getControllerMain().updateStatus(UserStatus.getByName(json.get("payload").getAsString()));
  4.                         break;
  5.                     case "@WS/MESSAGE/ONLINE_COUNT":
  6.                         App.getControllerMain().updateOnline(json.get("payload").getAsJsonObject().get("total_users").getAsInt(), json.get("payload").getAsJsonObject().get("registered_users").getAsInt());
  7.                         break;
  8.                     case "@WS/SUBSCRIPTIONS/MOST_RECENT/NEW_ORDER":
  9.                         App.getControllerFeed().processOrder(App.getGson().fromJson(json.get("payload").getAsJsonObject().get("order").getAsJsonObject(), new TypeToken<Order>() {}.getType()));
  10.                         break;
  11.                     case "@WS/chats/MESSAGE_SENT":
  12.                         App.getControllerChats().processMessage(App.getGson().fromJson(json.get("payload").getAsJsonObject().get("message").getAsJsonObject(), new TypeToken<ChatMessage>() {}.getType()), false);
  13.                         break;
  14.                     case "@WS/chats/NEW_MESSAGE":
  15.                         App.getControllerChats().processMessage(App.getGson().fromJson(json.get("payload").getAsJsonObject(), new TypeToken<ChatMessage>() {}.getType()), true);
  16.                         break;
  17.                     default:
  18.                         System.out.println(message);
  19.                 }
  20.  
  21.  
  22.  
  23.  
  24.  
  25.     public void setStatus(UserStatus status) {
  26.         if (!Settings.getInstance().isLogined())
  27.             return;
  28.         JsonObject request = new JsonObject();
  29.         request.add("type", new JsonPrimitive("@WS/USER/SET_STATUS"));
  30.         request.add("payload", new JsonPrimitive(status.name().toLowerCase()));
  31.  
  32.         this.send(request);
  33.     }
  34.  
  35.     public void subscribeMostRecent() {
  36.         JsonObject request = new JsonObject();
  37.         request.add("type", new JsonPrimitive("@WS/SUBSCRIBE/MOST_RECENT"));
  38.  
  39.         this.send(request);
  40.     }
  41.  
  42.     public void sendMessage(String chatId, String message) {
  43.         if (!Settings.getInstance().isLogined())
  44.             return;
  45.         JsonObject payload = new JsonObject();
  46.         payload.add("chat_id", new JsonPrimitive(chatId));
  47.         payload.add("message", new JsonPrimitive(message));
  48.         payload.add("temp_id", new JsonPrimitive(this.getSaltString()));
  49.  
  50.         JsonObject request = new JsonObject();
  51.         request.add("type", new JsonPrimitive("@WS/chats/SEND_MESSAGE"));
  52.         request.add("payload", payload);
  53.  
  54.         this.send(request);
  55.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top