Skip to content

Commit

Permalink
Added websocket latency
Browse files Browse the repository at this point in the history
  • Loading branch information
johnforte committed Oct 6, 2017
1 parent b8cacf4 commit 9fb85f1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
8 changes: 7 additions & 1 deletion DetectRTC.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

// Last Updated On: 2017-08-31 6:52:39 AM UTC
// Last Updated On: 2017-10-06 7:53:56 PM UTC

// ________________
// DetectRTC v1.3.5
Expand Down Expand Up @@ -974,9 +974,15 @@
DetectRTC.checkWebSocketsSupport = function(callback) {
callback = callback || function() {};
try {
var starttime;
var websocket = new WebSocket('wss://echo.websocket.org:443/');
websocket.onopen = function() {
DetectRTC.isWebSocketsBlocked = false;
starttime = (new Date).getTime();
websocket.send('ping');
};
websocket.onmessage = function() {
DetectRTC.WebsocketLatency = (new Date).getTime() - starttime + 'ms';
callback();
websocket.close();
websocket = null;
Expand Down
Loading

0 comments on commit 9fb85f1

Please sign in to comment.