Advertisement
Guest User

Stanza.io jingle

a guest
Dec 10th, 2017
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var XMPP_DOMAIN  = xms;
  2. var xmpp_user    = // xmpp user name
  3. navigator.getUserMedia = ( navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
  4.  
  5. var localAudio_stream;
  6. navigator.getUserMedia({audio:true}, function(s){
  7.   localAudio_stream = s;
  8. }, function(){
  9.   alert("Audio Not Allowed");
  10. });
  11. var client = XMPP.createClient({
  12.   jid: "user_jid",
  13.   password: "user_password",
  14.   transport: 'websocket',
  15.   wsURL: "wss://domaine_name:5280/websocket/"
  16. });
  17. client.jingle.config.debug = true;
  18. client.jingle.addICEServer({
  19.     urls: 'turn:a_valid_turn_server_with_port',
  20.     username: 'turn_user',
  21.     credential: 'turn_pass'
  22. });
  23. client.on('session:started', function () {
  24.   client.enableCarbons();
  25.   client.getRoster(function (err, resp) {
  26.     client.updateCaps();
  27.     client.sendPresence({
  28.       caps: client.disco.caps
  29.     });
  30.   });
  31. });
  32.  
  33. client.on('jingle:remotestream:added', function (session, stream) {
  34.   attachMediaStream(stream, document.getElementById('remoteAudio'));
  35.   document.getElementById('remoteAudio').play();
  36. });
  37.  
  38. client.on('jingle:incoming', function (session) {
  39.   session.addStream(localAudio_stream);
  40.   session.accept();
  41. });
  42.  
  43. client.connect();
  44.  
  45.  
  46. function callJID(full_jid){
  47.   var session = client.jingle.createMediaSession(full_jid);
  48.   session.addStream(localAudio_stream);
  49.   session.start();
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement