daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest Oct 16th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.admin.sampleproj;
  2.  
  3. import android.util.Log;
  4.  
  5. import com.heroiclabs.nakama.ChannelPresenceEvent;
  6. import com.heroiclabs.nakama.Error;
  7. import com.heroiclabs.nakama.Match;
  8. import com.heroiclabs.nakama.MatchData;
  9. import com.heroiclabs.nakama.MatchPresenceEvent;
  10. import com.heroiclabs.nakama.MatchmakerMatched;
  11. import com.heroiclabs.nakama.StatusPresenceEvent;
  12. import com.heroiclabs.nakama.StreamData;
  13. import com.heroiclabs.nakama.StreamPresenceEvent;
  14. import com.heroiclabs.nakama.UserPresence;
  15. import com.heroiclabs.nakama.api.ChannelMessage;
  16. import com.heroiclabs.nakama.api.NotificationList;
  17.  
  18. import java.util.concurrent.ExecutionException;
  19.  
  20. public class NakamaHelper extends Manager{
  21.  
  22.     String log = new String("NakamaHelper");
  23.  
  24.     public NakamaHelper(String Host) {
  25.  
  26.         super(Host);
  27.     }
  28.  
  29.     @Override
  30.     public void handleDisconnect(Throwable throwable){
  31.         Log.i(log,"Inside Disconnect Handler "+throwable.getCause() +": :"+throwable.getMessage());
  32.     }
  33.  
  34.  
  35.     @Override
  36.     public void handleError(Error error){
  37.         Log.i(log,"Inside Error Handler "+error.getCause() +": :"+error.getMessage());
  38.     }
  39.  
  40.     @Override
  41.     public void handleChannelMessage(ChannelMessage channelMessage){
  42.         Log.i(log,"Inside ChannelMessage Handler "+channelMessage.getContent() +": :"+channelMessage.getChannelId());
  43.     }
  44.  
  45.  
  46.     @Override
  47.     public void handleChannelPresence(ChannelPresenceEvent channelPresenceEvent){
  48.         Log.i(log,"Inside ChannelPresence Handler "+channelPresenceEvent.getLeaves() +": :"+channelPresenceEvent.getJoins());
  49.     }
  50.  
  51.  
  52.     @Override
  53.     public void handleMatchmakeMatched(MatchmakerMatched matchmakerMatched){
  54.  
  55.  
  56.         Log.i(log,"Inside MatchmakerMatched Callback, matchmakerMatched.getToken() is : "+matchmakerMatched.getToken());
  57.  
  58.  
  59.         try {
  60.  
  61.             Match match = socket.joinMatchToken(matchmakerMatched.getToken()).get();
  62.  
  63.  
  64.             for (UserPresence presence : match.getPresences()) {
  65.                Log.i(log,"User  name "+ presence.getUserId() +" : : :"+ presence.getUsername());
  66.             }
  67.  
  68.         } catch (InterruptedException e) {
  69.             e.printStackTrace();
  70.         } catch (ExecutionException e) {
  71.             e.printStackTrace();
  72.         }
  73.  
  74.     }
  75.  
  76.  
  77.     @Override
  78.     public void handleMatchData(MatchData matchData){
  79.         Log.i(log,"Inside MatchData Handler "+matchData.getMatchId() );
  80.     }
  81.  
  82.  
  83.     @Override
  84.     public void handleMatchPresence(MatchPresenceEvent matchPresenceEvent){
  85.         Log.i(log,"Inside MatchPresenceEvent Handler "+matchPresenceEvent.getJoins() +": :"+matchPresenceEvent.getLeaves());
  86.     }
  87.  
  88.  
  89.     @Override
  90.     public void handleNotifications(NotificationList notificationList){
  91.         Log.i(log,"Inside NotificationList Handler "+notificationList.getNotifications(0) );
  92.     }
  93.  
  94.  
  95.     @Override
  96.     public void handleStatusPresence(StatusPresenceEvent statusPresenceEvent){
  97.         Log.i(log,"Inside StatusPresenceEvent Handler "+statusPresenceEvent.getJoins() +": :"+statusPresenceEvent.getLeaves());
  98.     }
  99.  
  100.  
  101.     @Override
  102.     public void handleStreamPresence(StreamPresenceEvent streamPresenceEvent){
  103.         Log.i(log,"Inside Disconnect Handler "+streamPresenceEvent.getLeaves() +": :"+streamPresenceEvent.getStream());
  104.     }
  105.  
  106.  
  107.     @Override
  108.     public void handleStreamdata(StreamData streamData){
  109.         Log.i(log,"Inside Disconnect Handler "+streamData.getData() +": :"+streamData.getSender());
  110.     }
  111. }
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