mirror of
https://github.com/onyx-and-iris/obsws-python.git
synced 2024-11-22 12:50:53 +00:00
check for response type in req
This commit is contained in:
parent
c8f2b6419d
commit
5532ecef03
@ -1,6 +1,7 @@
|
|||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
|
import time
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from random import randint
|
from random import randint
|
||||||
@ -16,6 +17,8 @@ Subs = IntEnum(
|
|||||||
|
|
||||||
|
|
||||||
class ObsClient(object):
|
class ObsClient(object):
|
||||||
|
DELAY = 0.001
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
defaultkwargs = {key: None for key in ["host", "port", "password"]}
|
defaultkwargs = {key: None for key in ["host", "port", "password"]}
|
||||||
kwargs = defaultkwargs | kwargs
|
kwargs = defaultkwargs | kwargs
|
||||||
@ -75,7 +78,7 @@ class ObsClient(object):
|
|||||||
"d": {
|
"d": {
|
||||||
"rpcVersion": 1,
|
"rpcVersion": 1,
|
||||||
"authentication": auth,
|
"authentication": auth,
|
||||||
"eventSubscriptions": (all_non_high_volume),
|
"eventSubscriptions": all_non_high_volume,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,4 +101,8 @@ class ObsClient(object):
|
|||||||
"d": {"requestType": req_type, "requestId": randint(1, 1000)},
|
"d": {"requestType": req_type, "requestId": randint(1, 1000)},
|
||||||
}
|
}
|
||||||
self.ws.send(json.dumps(payload))
|
self.ws.send(json.dumps(payload))
|
||||||
return json.loads(self.ws.recv())
|
response = json.loads(self.ws.recv())
|
||||||
|
while "requestId" not in response["d"]:
|
||||||
|
response = json.loads(self.ws.recv())
|
||||||
|
time.sleep(self.DELAY)
|
||||||
|
return response["d"]
|
||||||
|
Loading…
Reference in New Issue
Block a user