openbmclapi-rs/request_cert.py

43 lines
1.1 KiB
Python
Raw Permalink Normal View History

2024-02-08 23:59:36 +08:00
import time
import socketio
import tomli
cluster_config = tomli.load(open("config.toml", "rb"))
sio = socketio.Client()
center = "https://openbmclapi.bangbang93.com"
if __name__ == "__main__":
cluster_id = cluster_config["cluster_id"]
cluster_secret = cluster_config["cluster_secret"]
"""
this.socket = connect(this.prefixUrl, {
transports: ['websocket'],
query: {
clusterId: this.clusterId,
clusterSecret: this.clusterSecret,
},
})
"""
connect_url = f"{center}?clusterId={cluster_id}&clusterSecret={cluster_secret}"
sio.connect(connect_url, transports="websocket")
print("connected")
time.sleep(1)
"""
const cert = await new Promise<{cert: string; key: string}>((resolve, reject) => {
this.socket?.emit('request-cert', ([err, cert]: [unknown, {cert: string; key: string}]) => {
if (err) return reject(err)
resolve(cert)
})
2024-02-10 12:17:55 +08:00
})
"""
2024-02-08 23:59:36 +08:00
# sio.emit("request-cert",)
sio.emit("request-cert", callback=lambda *args: print(args))
time.sleep(10)