e66598d77f
commit dd00d53895b824fbe4170c4a34b104303f722ccd
Merge: 2b3698e
cb9ea12
Author: Robin Linus <robin_woll@capira.de>
Date: Wed Feb 10 00:27:32 2016 -0600
Merge branch 'name-device' into merge123
# Conflicts:
# app/elements/buddy-finder/buddy-avatar.html
# app/elements/buddy-finder/buddy-finder.html
# app/elements/buddy-finder/personal-avatar.html
# app/index.html
commit cb9ea1235001f0cc23514cb622ce711cdc0538af
Author: Robin Linus <robin_woll@capira.de>
Date: Tue Feb 9 23:43:49 2016 -0600
#13 Feature Request: Name your device
commit 6fa43b56f4e705a19e68b62bc671a4948b6968fb
Author: Robin Linus <robin_woll@capira.de>
Date: Fri Jan 1 19:54:56 2016 +0100
Initial
commit fc55c86f5cf95039355d85be7409e68f27246696
Author: Robin Linus <robin_woll@capira.de>
Date: Fri Jan 1 18:06:27 2016 +0100
Fix fullscreen layout on iOS
59 lines
2.1 KiB
HTML
59 lines
2.1 KiB
HTML
<link rel="import" href="p2p-network.html">
|
|
<link rel="import" href="web-socket.html">
|
|
<dom-module id="connection-wrapper">
|
|
<template>
|
|
<p2p-network id="p2p" me="{{me}}"></p2p-network>
|
|
<web-socket id="ws" me="{{me}}"></web-socket>
|
|
</template>
|
|
<script>
|
|
'use strict';
|
|
(function() {
|
|
window.webRTCSupported = !!(window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection || window.webkitRTCPeerConnection);
|
|
|
|
function rtcConnectionSupported(peerId) {
|
|
return window.webRTCSupported && (peerId.indexOf('rtc_') === 0);
|
|
}
|
|
Polymer({
|
|
is: 'connection-wrapper',
|
|
properties: {
|
|
me: {
|
|
notify: true
|
|
},
|
|
},
|
|
behaviors: [Chat.FileTransferProtocol],
|
|
_sendFile: function(toPeer, file) {
|
|
if (!rtcConnectionSupported(toPeer)) {
|
|
this.$.ws._sendFile(toPeer, file);
|
|
} else {
|
|
this.$.p2p._sendFile(toPeer, file);
|
|
}
|
|
},
|
|
_sendSystemEvent: function(toPeer, event) {
|
|
console.log('system event', toPeer, event);
|
|
if (!rtcConnectionSupported(toPeer)) {
|
|
this.$.ws._sendSystemEvent(toPeer, event);
|
|
} else {
|
|
this.$.p2p._sendSystemEvent(toPeer, event);
|
|
}
|
|
},
|
|
connectToPeer: function(toPeer, callback) {
|
|
if (!rtcConnectionSupported(toPeer)) {
|
|
callback();
|
|
} else {
|
|
this.$.p2p.connectToPeer(toPeer, callback);
|
|
}
|
|
},
|
|
_onHandshake: function(event) {
|
|
var me = event.uuid;
|
|
this.set('me', me);
|
|
if (window.webRTCSupported) {
|
|
this.$.p2p.initialize();
|
|
}
|
|
},
|
|
notifyServer: function(msg) {
|
|
this.$.ws.client.send({}, msg);
|
|
}
|
|
});
|
|
})();
|
|
</script>
|
|
</dom-module>
|