|
|
@@ -0,0 +1,39 @@ |
|
|
|
// Interface for testing, provides testing data, and dynamic updates, etc. |
|
|
|
|
|
|
|
//jquery |
|
|
|
#include "jquery.js" |
|
|
|
|
|
|
|
// WebSocket emulation class for testing |
|
|
|
function WebSocketTest(actions) { |
|
|
|
this.actions = actions.slice(); // copy |
|
|
|
this.actions.reverse() |
|
|
|
this.processNextItem() |
|
|
|
} |
|
|
|
|
|
|
|
// WebSocketTest.prototype.send = function () |
|
|
|
// WebSocketTest.prototype.close = function () |
|
|
|
|
|
|
|
// Internal |
|
|
|
WebSocketTest.prototype.processNextItem = function () { |
|
|
|
var item = this.actions.pop() |
|
|
|
var wst = this; |
|
|
|
setTimeout(function() { |
|
|
|
item[1](wst); |
|
|
|
wst.processNextItem(); |
|
|
|
}, item[0]); |
|
|
|
|
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
// Setup the socket that will be used |
|
|
|
var socket = new WebSocketTest([ |
|
|
|
[ 10, function(a) { a.onopen(new Object()) } ], |
|
|
|
[ 10, function(a) { a.onmessage(new MessageEvent('websockettest', { |
|
|
|
data : 'p .123' |
|
|
|
})) } ], |
|
|
|
[ 2000, function(a) { a.onmessage(new MessageEvent('websockettest', { |
|
|
|
data : 'p .234' |
|
|
|
})) } ], |
|
|
|
]); |
|
|
|
|
|
|
|
#include "solardash.base.js" |