1.2 KiB
1.2 KiB
How to use
- Install G2O WebSocket module to your server
- Download include/ folder and import the Squirrel part of the library:
<import src="include/pyg2o.exml" />
- Install python library to your application
pip install git+https://github.com/AURUMVORXX/PyG2O.git
- Launch websocket client in your Squirrel scripts
// PyG2O(url, silent, max_reconnect_attempts)
// silent - disable information prints
// max_reconnect_attempts - maximum reconnect attempts if server will stop the connection (0 - infinite attempts). This value doesn't reset on connection
// Start server
local srv = PyG2O("ws://localhost:8080", true, 15)
srv.start()
// Stop server
srv.stop()
- In your application, launch asyncio event loop and websocket server
import pyg2o
import asyncio
srv = None
async def main():
global srv
srv = pyg2o.PythonWebsocketServer(
host='localhost',
port=8080,
ping_interval=30,
silent=False,
whitelist=['::1'],
# logger = YOUR_LOGGER,
)
try:
await srv.start()
except asyncio.CancelledError:
await srv.stop()
if __name__ == '__main__':
asyncio.run(main())