Adding websockets for panel (trying at least)
This commit is contained in:
parent
58517fba53
commit
2ac9e75dac
2 changed files with 29 additions and 4 deletions
|
|
@ -57,7 +57,27 @@
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initCamera()
|
this.initCamera()
|
||||||
},
|
},
|
||||||
created: function () {}
|
created: function () {
|
||||||
|
console.log('{{ copilot.id }}')
|
||||||
|
|
||||||
|
console.log('Starting connection to WebSocket Server')
|
||||||
|
this.connection = new WebSocket(
|
||||||
|
'wss://' +
|
||||||
|
document.domain +
|
||||||
|
':' +
|
||||||
|
location.port +
|
||||||
|
'/ws/{{ copilot.id }}'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.connection.onmessage = function (event) {
|
||||||
|
console.log(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.connection.onopen = function (event) {
|
||||||
|
console.log(event)
|
||||||
|
console.log('Successfully connected to the echo websocket server...')
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from quart import g, abort, render_template, jsonify
|
from quart import g, abort, render_template, jsonify, websocket
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
|
||||||
from lnbits.decorators import check_user_exists, validate_uuids
|
from lnbits.decorators import check_user_exists, validate_uuids
|
||||||
|
|
@ -6,7 +6,6 @@ from lnbits.decorators import check_user_exists, validate_uuids
|
||||||
from . import copilot_ext
|
from . import copilot_ext
|
||||||
from .crud import get_copilot
|
from .crud import get_copilot
|
||||||
|
|
||||||
|
|
||||||
@copilot_ext.route("/")
|
@copilot_ext.route("/")
|
||||||
@validate_uuids(["usr"], required=True)
|
@validate_uuids(["usr"], required=True)
|
||||||
@check_user_exists()
|
@check_user_exists()
|
||||||
|
|
@ -27,3 +26,9 @@ async def panel(copilot_id):
|
||||||
HTTPStatus.NOT_FOUND, "Copilot link does not exist."
|
HTTPStatus.NOT_FOUND, "Copilot link does not exist."
|
||||||
)
|
)
|
||||||
return await render_template("copilot/panel.html", copilot=copilot)
|
return await render_template("copilot/panel.html", copilot=copilot)
|
||||||
|
|
||||||
|
@copilot_ext.websocket('/ws/<copilot_id>')
|
||||||
|
async def ws():
|
||||||
|
while True:
|
||||||
|
data = await websocket.receive()
|
||||||
|
await websocket.send(f"echo {data}")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue