沖様
以下、当方で確実に再現するソースになります。
SkyWayキーを変更してご確認ください。
確認環境
MacBook Pro (15-inch, Mid 2012)
OSX Yosemite 10.10.4
Chrome 44
※スリープ時間は5分から30分程度で試しております。
どうぞよろしくお願いいたします。
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="-1">
<title></title>
</head>
<body>
<button type="button" class="start">スタート</button>
<button type="button" class="status">ステータス</button>
<script>
var SkyWayParams = {
config : {
skyWay : {
key : 'ここをSkyWayキーに置き換えてください',
turn : true,
config : {
'iceServers': [{'url': 'stun:stun.skyway.io:3478'}]
},
debug : 3
},
},
peer : null,
};
var PeerUtils = {
destroyPeer: function()
{
console.log('['+Date.now()+'] [PeerUtils] destroyPeer:');
if (SkyWayParams.peer === null)
{
console.log('['+Date.now()+'] peer is null');
return true;
}
if (SkyWayParams.peer.destroyed === false)
{
SkyWayParams.peer.destroy();
}
return false;
},
clearPeer: function()
{
console.log('['+Date.now()+'] [PeerUtils] clearPeer:');
if (SkyWayParams.peer === null)
{
console.log('['+Date.now()+'] peer is null');
return;
}
SkyWayParams.peer.off('open');
SkyWayParams.peer.off('error');
SkyWayParams.peer = null;
},
initPeer: function()
{
console.log('['+Date.now()+'] [PeerUtils] initPeer:');
if (PeerUtils.destroyPeer() === false)
return;
PeerUtils.clearPeer();
SkyWayParams.peer = new Peer( SkyWayParams.config.skyWay );
SkyWayParams.peer.on('open', PeerUtils.peerEvents.open);
SkyWayParams.peer.on('close', PeerUtils.peerEvents.close);
SkyWayParams.peer.on('error', PeerUtils.peerEvents.error);
},
peerEvents:
{
open: function(id)
{
PeerUtils.peerStatus();
},
close: function()
{
PeerUtils.peerStatus();
PeerUtils.clearPeer();
},
error: function(error)
{
console.log('['+Date.now()+'] type: ', error.type);
console.log('['+Date.now()+'] message: ', error.message);
PeerUtils.peerStatus();
if (error.type !== 'peer-unavailable')
PeerUtils.clearPeer();
}
},
peerStatus: function()
{
console.log('['+Date.now()+'] [PeerUtils] status:');
console.log('['+Date.now()+'] >>>>>>>>>>>>>>>>>>>');
if (SkyWayParams.peer)
{
console.log('['+Date.now()+'] disconnected: ', SkyWayParams.peer.disconnected);
console.log('['+Date.now()+'] destroyed: ', SkyWayParams.peer.destroyed);
}
else
{
console.log('['+Date.now()+'] peer is null');
}
console.log('['+Date.now()+'] <<<<<<<<<<<<<<<<<<<');
}
};
//------------------------------------
// UI操作
$(function(){
$('.status').on('click', function(){
PeerUtils.peerStatus();
});
$('.start').on('click', function(){
PeerUtils.initPeer();
});
});
</script>
</body>
</html>
2015年8月3日月曜日 22時52分11秒 UTC+9 Yusuke NAKA: