SHARE
TWEET

Untitled

a guest Jun 7th, 2017 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.jadefrh.nightylogin;
  2.  
  3. import android.content.Intent;
  4. import android.content.SharedPreferences;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.os.Bundle;
  7.  
  8. import com.quickblox.auth.Consts;
  9. import com.quickblox.auth.QBAuth;
  10. import com.quickblox.auth.model.QBSession;
  11. import com.quickblox.chat.QBChatService;
  12. import com.quickblox.chat.QBSignaling;
  13. import com.quickblox.chat.QBWebRTCSignaling;
  14. import com.quickblox.chat.listeners.QBVideoChatSignalingManagerListener;
  15. import com.quickblox.core.QBEntityCallback;
  16. import com.quickblox.core.QBSettings;
  17. import com.quickblox.core.exception.QBResponseException;
  18. import com.quickblox.users.model.QBUser;
  19. import com.quickblox.videochat.webrtc.QBRTCClient;
  20. import com.quickblox.videochat.webrtc.QBRTCConfig;
  21.  
  22. import static com.jadefrh.nightylogin.InitActivity.MY_PREFS_NAME;
  23.  
  24. public class VideoActivity extends AppCompatActivity {
  25.  
  26.     private String qbLogin;
  27.     private String qbPassword = "Fa8grOp89bKgi76gFPsm";
  28.  
  29.     static final String APP_ID = "57763";
  30.     static final String AUTH_KEY = "FAd4zvhKvsALGwD";
  31.     static final String AUTH_SECRET = "f2DFnCfrkcmvepE";
  32.     static final String ACCOUNT_KEY = "RyqpYix2Y54TzqeSACQs";
  33.  
  34.     private QBRTCClient rtcClient;
  35.  
  36.     @Override
  37.     protected void onCreate(Bundle savedInstanceState) {
  38.         super.onCreate(savedInstanceState);
  39.         setContentView(R.layout.activity_video);
  40.  
  41.         Intent i = getIntent();
  42.         Integer quickblox_id = i.getIntExtra("quickblox_id", 0);
  43.         Integer user_id = i.getIntExtra("user_id", 0);
  44.         Integer call_max_duration = i.getIntExtra("call_max_duration", 0);
  45.         Integer call_ring_duration = i.getIntExtra("call_ring_duration", 0);
  46.         Integer call_delay_interaction = i.getIntExtra("call_delay_interaction", 0);
  47.  
  48.         System.out.println("quickblox : " + quickblox_id);
  49.  
  50.         SharedPreferences prefs = this.getSharedPreferences(MY_PREFS_NAME, this.MODE_PRIVATE);
  51.         qbLogin = prefs.getString("user_email", null);
  52.  
  53.         QBSettings.getInstance().init(getApplicationContext(), APP_ID, AUTH_KEY, AUTH_SECRET);
  54.         QBSettings.getInstance().setAccountKey(ACCOUNT_KEY);
  55.  
  56.  
  57.         final QBUser user = new QBUser(qbLogin, qbPassword);
  58.  
  59.         // CREATE SESSION WITH USER
  60.         // If you use create session with user data,
  61.         // then the user will be logged in automatically
  62.         QBAuth.createSession(qbLogin, qbPassword, new QBEntityCallback<QBSession>() {
  63.             @Override
  64.             public void onSuccess(QBSession session, Bundle bundle) {
  65.  
  66.                 user.setId(session.getUserId());
  67.                 // INIT CHAT SERVICE
  68.                 QBChatService chatService = QBChatService.getInstance();
  69.  
  70. //                // LOG IN CHAT SERVICE
  71.                 chatService.login(user, new QBEntityCallback<QBUser>() {
  72.  
  73.                     @Override
  74.                     public void onSuccess(QBUser qbUser, Bundle bundle) {
  75.                         //success
  76.                     }
  77.  
  78.                     @Override
  79.                     public void onError(QBResponseException errors) {
  80.                         //error
  81.                     }
  82.                 });
  83.             }
  84.  
  85.             @Override
  86.             public void onError(QBResponseException errors) {
  87.                 //error
  88.             }
  89.         });
  90.  
  91.         //initQBRTCClient();
  92.  
  93.     }
  94.  
  95.     private void initQBRTCClient() {
  96.         rtcClient = QBRTCClient.getInstance(this);
  97.  
  98.         System.out.println("tu rentres ici ??????? ");
  99.         QBChatService.getInstance().getVideoChatWebRTCSignalingManager()
  100.                 .addSignalingManagerListener(new QBVideoChatSignalingManagerListener() {
  101.                     @Override
  102.                     public void signalingCreated(QBSignaling qbSignaling, boolean createdLocally) {
  103.                         if (!createdLocally) {
  104.                             rtcClient.addSignaling((QBWebRTCSignaling) qbSignaling);
  105.                         }
  106.                     }
  107.                 });
  108.     }
  109.    
  110. }
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