mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
cleanup
This commit is contained in:
parent
4612ca70c7
commit
2eff5ebc7b
2 changed files with 106 additions and 109 deletions
|
@ -514,17 +514,6 @@ gotMQTTMsg( int len, const uint8_t* msg )
|
|||
XP_LOGFF( "got msg of len %d", len );
|
||||
|
||||
dvc_parseMQTTPacket( sGlobals->dutil, NULL, msg, len );
|
||||
|
||||
/* XWStreamCtxt* stream = mem_stream_make_raw( MPPARM(sGlobals->mpool) */
|
||||
/* sGlobals->vtMgr ); */
|
||||
/* stream_putBytes( stream, msg, len ); */
|
||||
/* NetLaunchInfo nli; */
|
||||
/* XP_Bool valid = nli_makeFromStream( &nli, stream ); */
|
||||
/* stream_destroy( stream, NULL ); */
|
||||
|
||||
/* if ( valid ) { */
|
||||
/* dutil_onInviteReceived( sGlobals->dutil, NULL, &nli ); */
|
||||
/* } */
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,125 +1,132 @@
|
|||
<!doctype html>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<style>
|
||||
canvas.emscripten {
|
||||
border: 0px none;
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
display:block;
|
||||
}
|
||||
p.startButton {
|
||||
text-align: center;
|
||||
background-color: #4c7aff;
|
||||
font-family: Sans-Serif;
|
||||
padding: 10px;
|
||||
}
|
||||
#loadingDiv {
|
||||
text-align: center;
|
||||
}
|
||||
div.buttons {
|
||||
text-align: center;
|
||||
}
|
||||
canvas.emscripten {
|
||||
border: 0px none;
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
display:block;
|
||||
}
|
||||
p.startButton {
|
||||
text-align: center;
|
||||
background-color: #4c7aff;
|
||||
font-family: Sans-Serif;
|
||||
padding: 10px;
|
||||
}
|
||||
#loadingDiv {
|
||||
text-align: center;
|
||||
}
|
||||
div.buttons {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var client = null;
|
||||
function callNewGame() {
|
||||
var args = [
|
||||
document.getElementById("player0Checked").checked,
|
||||
document.getElementById("player1Checked").checked,
|
||||
]
|
||||
Module.ccall('newgame', null, ['boolean', 'boolean'], args);
|
||||
}
|
||||
var client = null;
|
||||
function callNewGame() {
|
||||
var args = [
|
||||
document.getElementById("player0Checked").checked,
|
||||
document.getElementById("player1Checked").checked,
|
||||
]
|
||||
Module.ccall('newgame', null, ['boolean', 'boolean'], args);
|
||||
}
|
||||
|
||||
function onHaveDevID(devid) {
|
||||
console.log('got ' + devid);
|
||||
document.getElementById("mqtt_span").textContent=devid;
|
||||
// called from main.c
|
||||
function onHaveDevID(devid) {
|
||||
console.log('got ' + devid);
|
||||
document.getElementById("mqtt_span").textContent=devid;
|
||||
|
||||
client = new Paho.MQTT.Client("eehouse.org", 8883, '/wss', devid);
|
||||
client = new Paho.MQTT.Client("eehouse.org", 8883, '/wss', devid);
|
||||
|
||||
// set callback handlers
|
||||
client.onConnectionLost = function onConnectionLost(responseObject) {
|
||||
document.getElementById("mqtt_status").textContent="Disconnected";
|
||||
if (responseObject.errorCode !== 0) {
|
||||
console.log("onConnectionLost:"+responseObject.errorMessage);
|
||||
}
|
||||
};
|
||||
client.onMessageArrived = function onMessageArrived(message) {
|
||||
var payload = message.payloadBytes;
|
||||
var length = payload.length;
|
||||
Module.ccall('gotMQTTMsg', null, ['number', 'array'], [length, payload]);
|
||||
};
|
||||
// set callback handlers
|
||||
client.onConnectionLost = function onConnectionLost(responseObject) {
|
||||
document.getElementById("mqtt_status").textContent="Disconnected";
|
||||
if (responseObject.errorCode !== 0) {
|
||||
console.log("onConnectionLost:"+responseObject.errorMessage);
|
||||
}
|
||||
};
|
||||
client.onMessageArrived = function onMessageArrived(message) {
|
||||
var payload = message.payloadBytes;
|
||||
var length = payload.length;
|
||||
Module.ccall('gotMQTTMsg', null, ['number', 'array'], [length, payload]);
|
||||
};
|
||||
|
||||
function onConnect() {
|
||||
document.getElementById("mqtt_status").textContent="Connected";
|
||||
function onConnect() {
|
||||
document.getElementById("mqtt_status").textContent="Connected";
|
||||
|
||||
var subscribeOptions = {
|
||||
qos: 2, // QoS
|
||||
// invocationContext: {foo: true}, // Passed to success / failure callback
|
||||
// onSuccess: function() { alert('subscribe succeeded'); },
|
||||
onFailure: function() { alert('subscribe failed'); },
|
||||
timeout: 10,
|
||||
};
|
||||
client.subscribe('xw4/device/' + devid, subscribeOptions);
|
||||
var subscribeOptions = {
|
||||
qos: 2, // QoS
|
||||
// invocationContext: {foo: true}, // Passed to success / failure callback
|
||||
// onSuccess: function() { alert('subscribe succeeded'); },
|
||||
onFailure: function() { alert('subscribe failed'); },
|
||||
timeout: 10,
|
||||
};
|
||||
client.subscribe('xw4/device/' + devid, subscribeOptions);
|
||||
|
||||
// Try a send-to-self for sanity
|
||||
// message = new Paho.MQTT.Message("Hello");
|
||||
// message.destinationName = devid;
|
||||
// client.send(message);
|
||||
}
|
||||
// Try a send-to-self for sanity
|
||||
// message = new Paho.MQTT.Message("Hello");
|
||||
// message.destinationName = devid;
|
||||
// client.send(message);
|
||||
}
|
||||
|
||||
// connect the client -- throws SecurityError: “The operation is insecure.”
|
||||
client.connect({"mqttVersion": 3,
|
||||
"userName": "xwuser",
|
||||
"password": "xw4r0cks",
|
||||
"useSSL": true,
|
||||
"reconnect": true,
|
||||
"onSuccess": onConnect,
|
||||
"onFailure": function() { alert('onFailure'); },
|
||||
});
|
||||
}
|
||||
// connect the client -- throws SecurityError: “The operation is insecure.”
|
||||
client.connect({"mqttVersion": 3,
|
||||
"userName": "xwuser",
|
||||
"password": "xw4r0cks",
|
||||
"useSSL": true,
|
||||
"reconnect": true,
|
||||
"onSuccess": onConnect,
|
||||
"onFailure": function() { alert('onFailure'); },
|
||||
});
|
||||
}
|
||||
|
||||
function mqttSend (topic, ptr) {
|
||||
if ( null != client ) {
|
||||
message = new Paho.MQTT.Message(ptr);
|
||||
message.destinationName = topic;
|
||||
client.send(message);
|
||||
} else {
|
||||
alert('null client');
|
||||
}
|
||||
}
|
||||
function mqttSend (topic, ptr) {
|
||||
if ( null != client ) {
|
||||
message = new Paho.MQTT.Message(ptr);
|
||||
message.destinationName = topic;
|
||||
message.qos = 2;
|
||||
client.send(message);
|
||||
} else {
|
||||
alert('null client');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="loadingDiv">CrossWords is loading...</div>
|
||||
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
|
||||
<div class="buttons">
|
||||
<body>
|
||||
<div class="buttons">
|
||||
<div id="loadingDiv">CrossWords is loading...</div>
|
||||
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
|
||||
<div class="buttons">
|
||||
<button onclick="Module.ccall('button', null, ['string'], ['hintdown']);">Prev Hint</button>
|
||||
<button onclick="Module.ccall('button', null, ['string'], ['hintup']);">Next Hint</button>
|
||||
<button onclick="Module.ccall('button', null, ['string'], ['flip']);">Flip</button>
|
||||
<button onclick="Module.ccall('button', null, ['string'], ['redo']);">Un/Redo</button>
|
||||
<button onclick="Module.ccall('button', null, ['string'], ['vals']);">Vals</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="buttons">
|
||||
<div class="buttons">
|
||||
<span>Player 1</span>
|
||||
<input type="checkbox" id="player0Checked">Is Robot</input>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<span>Player 2</span>
|
||||
<input type="checkbox" id="player1Checked">Is Robot</input>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<button type="button" onclick="callNewGame();">New Local Game</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="buttons">
|
||||
<button type="button" onclick="localStorage.clear();">Clear Local Storage</button>
|
||||
</div>
|
||||
|
||||
<div><span>MQTT Dev ID:</span><span id="mqtt_span"></span></div>
|
||||
<div><span>MQTT Status:</span><span id="mqtt_status">Unconnected</span></div>
|
||||
<div><span>MQTT Dev ID:</span><span id="mqtt_span"></span></div>
|
||||
<div><span>MQTT Status:</span><span id="mqtt_status">Unconnected</span></div>
|
||||
|
||||
<script type='text/javascript'>
|
||||
<script type='text/javascript'>
|
||||
var Module = {
|
||||
onRuntimeInitialized: function() {
|
||||
var e = document.getElementById('loadingDiv');
|
||||
|
@ -131,9 +138,9 @@
|
|||
return canvas;
|
||||
})()
|
||||
};
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
<script>
|
||||
(function() {
|
||||
var memoryInitializer = 'main.js.mem';
|
||||
if (typeof Module['locateFile'] === 'function') {
|
||||
|
@ -153,8 +160,9 @@
|
|||
script = document.createElement('script');
|
||||
script.src = "paho-mqtt.js";
|
||||
document.body.appendChild(script);
|
||||
</script>
|
||||
</body>
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue