Search in sources :

Example 1 with SpectateRoomHandler

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

the class FragmentBase method spectate.

public void spectate(int p) {
    ThreadsHelper threadsHelper = (ThreadsHelper) threadListAdapter.getItem(p);
    String thread_id = threadsHelper.getThread_id();
    String type = "spectate";
    session = new SessionManager(getActivity().getApplicationContext());
    HashMap<String, String> user = session.getUserDetails();
    String username = user.get(SessionManager.KEY_NAME);
    SpectateRoomHandler spectateRoomHandler = new SpectateRoomHandler(getActivity().getApplicationContext());
    try {
        // Log.d("JOINSPECTATE", "yes");
        result = spectateRoomHandler.execute(type, thread_id, username).get();
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
    if (result.equals("Spectate room failed")) {
        Toast.makeText(getActivity(), "spectate room failed!", Toast.LENGTH_LONG).show();
    } else {
        chatRoomManager = new ChatRoomManager(getActivity().getApplicationContext());
        chatRoomManager.updateUserRoomSession(thread_id, null, "true");
        goToChat(result);
    }
}
Also used : SpectateRoomHandler(ingage.ingage20.handlers.SpectateRoomHandler) SessionManager(ingage.ingage20.managers.SessionManager) ChatRoomManager(ingage.ingage20.managers.ChatRoomManager) ExecutionException(java.util.concurrent.ExecutionException) ThreadsHelper(ingage.ingage20.helpers.ThreadsHelper)

Example 2 with SpectateRoomHandler

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

the class ChatActivity method onResume.

@Override
public void onResume() {
    super.onResume();
    Log.d("RESUMECHAT", "textRESUME ");
    HashMap<String, String> chat_user = chatRoomManager.getUserDetails();
    String spectator = chat_user.get(ChatRoomManager.SPECTATOR);
    // check from cache is user is spectator
    if (spectator.equals("true") && paused) {
        String type = "spectate";
        session = new SessionManager(getApplicationContext());
        HashMap<String, String> user = session.getUserDetails();
        String username = user.get(SessionManager.KEY_NAME);
        SpectateRoomHandler spectateRoomHandler = new SpectateRoomHandler(getApplicationContext());
        String result;
        setSpectateMode();
        try {
            result = spectateRoomHandler.execute(type, thread_id, username).get();
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }
        paused = false;
    }
}
Also used : SpectateRoomHandler(ingage.ingage20.handlers.SpectateRoomHandler) SessionManager(ingage.ingage20.managers.SessionManager) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with SpectateRoomHandler

use of ingage.ingage20.handlers.SpectateRoomHandler 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)

Example 4 with SpectateRoomHandler

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

the class ChatActivity method onPause.

@Override
public void onPause() {
    super.onPause();
    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")) {
        paused = 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", "textpause: " + result);
    }
}
Also used : SpectateRoomHandler(ingage.ingage20.handlers.SpectateRoomHandler) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

SpectateRoomHandler (ingage.ingage20.handlers.SpectateRoomHandler)4 ExecutionException (java.util.concurrent.ExecutionException)4 SessionManager (ingage.ingage20.managers.SessionManager)2 ChatRoomHandler (ingage.ingage20.handlers.ChatRoomHandler)1 ThreadsHelper (ingage.ingage20.helpers.ThreadsHelper)1 ChatRoomManager (ingage.ingage20.managers.ChatRoomManager)1