mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
A most inelegant hack.
This commit is contained in:
@@ -19,6 +19,9 @@ async def echo(websocket, path):
|
||||
elif message == "ping":
|
||||
print("<<[{}]".format(message))
|
||||
tx = pong(message)
|
||||
elif message == "importBooks":
|
||||
print("<<[{} cmd rcvd]\n Starting import".format(message))
|
||||
tx = "Starting Import . . ."
|
||||
await websocket.send(tx)
|
||||
|
||||
|
||||
|
||||
@@ -171,9 +171,8 @@ $(document).ready(function(){
|
||||
$('#pop_over_0').dialog("open");
|
||||
});
|
||||
$(document).on('click', '.logout-btn', function(){window.location.href = '/logout'});
|
||||
$(document).on('click', '.import-btn', function(){
|
||||
let connection = PyshelfServer(server);
|
||||
//ping(socket);
|
||||
$(document).on('click', '.import-btn', async function(){
|
||||
let connection = await ImportBooks(server);
|
||||
});
|
||||
$('#coll_button').on('click', function(){
|
||||
var isopen = $('#pop_over_0').dialog("isOpen");
|
||||
@@ -281,14 +280,31 @@ function OpenSocket(address) {
|
||||
resolve(connection);
|
||||
});
|
||||
}
|
||||
|
||||
function ImportBooks(address) {
|
||||
return new Promise(resolve => {
|
||||
const connection = new WebSocket(address);
|
||||
connection.onopen = function(e){
|
||||
sock_tx(connection,'importBooks')
|
||||
};
|
||||
connection.onmessage = function(rcvd){
|
||||
sock_rx(rcvd)
|
||||
};
|
||||
resolve(connection);
|
||||
});
|
||||
}
|
||||
|
||||
async function PyshelfServer(address){
|
||||
console.log("--[ Starting Connection ]")
|
||||
return await OpenSocket(address)
|
||||
}
|
||||
function sock_rx(rcvd) {
|
||||
if (rcvd.data == 'pong') { pong(rcvd.data) }
|
||||
if (rcvd.data == 'pong') { pong(rcvd) }
|
||||
else { console.log("<<[rx] :"+rcvd.data) }
|
||||
}
|
||||
function sock_tx(connection, msg) {
|
||||
connection.send(msg);
|
||||
}
|
||||
function sock_status(connection) {
|
||||
let buffered = connection.bufferedAmmount;
|
||||
let ready = connection.readyState;
|
||||
|
||||
Reference in New Issue
Block a user