Browse Source

- Fix a little bug in the Chat widget

pull/16/head
Jaussoin Timothée 12 years ago
parent
commit
1a4dcb82c1
  1. 2
      app/widgets/Chat/Chat.php
  2. 6
      tests/webrtc/index.html
  3. 22
      tests/webrtc/script.js

2
app/widgets/Chat/Chat.php

@ -274,7 +274,7 @@ class Chat extends WidgetBase
// We decode URL codes to send the correct message to the XMPP server
$m = new \moxl\MessagePublish();
$m->setTo($to)
->setEncrypted($encrypted)
//->setEncrypted($encrypted)
->setContent(htmlspecialchars(rawurldecode($message)));
if($muc)
$m->setMuc();

6
tests/webrtc/index.html

@ -6,12 +6,18 @@
<title>WebRTC Example</title>
<!-- Simple Client JS -->
<link type="text/css" href="style.css" rel="stylesheet"></link>
<script src="adapter.js" type="text/javascript"></script>
<script src="script.js" type="text/javascript"></script>
</head>
<body>
test
<video autoplay="true" id="camera-stream">
</video>
<script type="text/javascript">init();</script>
</body>

22
tests/webrtc/script.js

@ -6,6 +6,11 @@ var optional = {
optional: [DtlsSrtpKeyAgreement]
};
// Set up audio and video regardless of what devices are present.
var sdpConstraints = {'mandatory': {
'OfferToReceiveAudio': true,
'OfferToReceiveVideo': true }};
function onIceCandidate(event) {
/*if (event.candidate) {
sendMessage({type: 'candidate',
@ -35,6 +40,7 @@ function onError(err) {
}
function onOfferCreated(description) {
console.log(description);
offer = description;
pc.setLocalDescription(offer, onPc1LocalDescriptionSet, onError);
}
@ -53,8 +59,6 @@ function init() {
pc.onicecandidate = onIceCandidate;
pc.onsignalingstatechange = onSignalingStateChanged;
pc.oniceconnectionstatechange = onIceConnectionStateChanged;
pc.createOffer(onOfferCreated, onError);
} catch (e) {
console.log('Failed to create PeerConnection, exception: ' + e.message);
alert('Cannot create RTCPeerConnection object; \
@ -63,9 +67,9 @@ function init() {
}
if(getUserMedia) {
/*if (getUserMedia) {
if (getUserMedia) {
getUserMedia = getUserMedia.bind(navigator);
}*/
}
// Request the camera.
getUserMedia(
@ -77,12 +81,17 @@ function init() {
// Success Callback
function(localMediaStream) {
// Get a reference to the video element on the page.
//var vid = document.getElementById('camera-stream');
var vid = document.getElementById('camera-stream');
// Create an object URL for the video stream and use this
// to set the video source.
//vid.src = window.URL.createObjectURL(localMediaStream);
vid.src = window.URL.createObjectURL(localMediaStream);
console.log(localMediaStream);
pc.addStream(localMediaStream);
channel = pc.createDataChannel("visio");
pc.createOffer(onOfferCreated, onError);
},
// Error Callback
@ -97,6 +106,7 @@ function init() {
alert('Sorry, your browser does not support getUserMedia');
}
//channel = pc.createDataChannel("visio");
console.log(pc);

Loading…
Cancel
Save