Search in sources :

Example 6 with ChatRoomHandler

use of ingage.ingage20.handlers.ChatRoomHandler in project iNGAGE by davis123123.

the class ChatActivity method leaveRoom.

private void leaveRoom() {
    HashMap<String, String> chat_user = chatRoomManager.getUserDetails();
    String side = chat_user.get(ChatRoomManager.SIDE);
    String thread_id = chat_user.get(ChatRoomManager.THREAD_ID);
    String spectator = chat_user.get(ChatRoomManager.SPECTATOR);
    if (spectator.equals("true")) {
        String type = "leave_spectate";
        String result = null;
        HashMap<String, String> user = session.getUserDetails();
        String username = user.get(SessionManager.KEY_NAME);
        SpectateRoomHandler spectateRoomHandler = new SpectateRoomHandler(getApplicationContext());
        try {
            result = spectateRoomHandler.execute(type, thread_id, username, side).get();
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }
        Log.d("SPECTATORSTATE", "text: " + result);
    } else {
        String type = "leave";
        String result = null;
        HashMap<String, String> user = session.getUserDetails();
        String username = user.get(SessionManager.KEY_NAME);
        ChatRoomHandler chatRoomHandler = new ChatRoomHandler(getApplicationContext());
        try {
            result = chatRoomHandler.execute(type, thread_id, username, side).get();
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }
    }
    // leave user's session on cache
    chatRoomManager.updateUserRoomSession("", "", "");
}
Also used : ChatRoomHandler(ingage.ingage20.handlers.ChatRoomHandler) SpectateRoomHandler(ingage.ingage20.handlers.SpectateRoomHandler) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ChatRoomHandler (ingage.ingage20.handlers.ChatRoomHandler)6 ExecutionException (java.util.concurrent.ExecutionException)6 SessionManager (ingage.ingage20.managers.SessionManager)4 ChatRoomManager (ingage.ingage20.managers.ChatRoomManager)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RoomUserAdapter (ingage.ingage20.adapters.RoomUserAdapter)1 SpectateRoomHandler (ingage.ingage20.handlers.SpectateRoomHandler)1 ChatRoomUserHelper (ingage.ingage20.helpers.ChatRoomUserHelper)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1