mirror of
https://github.com/onyx-and-iris/obsws-python.git
synced 2024-11-22 04:40:53 +00:00
Merge pull request #30 from aatikturk/client_auth_loggers
auth logger for clients
This commit is contained in:
commit
ca72b92eb3
5
.gitignore
vendored
5
.gitignore
vendored
@ -45,6 +45,11 @@ env.bak/
|
|||||||
venv.bak/
|
venv.bak/
|
||||||
.hatch
|
.hatch
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
# For a library or package, you might want to ignore these files since the code is
|
||||||
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
|
.python-version
|
||||||
|
|
||||||
# Test/config
|
# Test/config
|
||||||
quick.py
|
quick.py
|
||||||
config.toml
|
config.toml
|
||||||
|
@ -108,9 +108,15 @@ class ObsClient:
|
|||||||
self.ws.send(json.dumps(payload))
|
self.ws.send(json.dumps(payload))
|
||||||
try:
|
try:
|
||||||
response = json.loads(self.ws.recv())
|
response = json.loads(self.ws.recv())
|
||||||
return response["op"] == 2
|
if response["op"] != 2:
|
||||||
|
raise OBSSDKError(
|
||||||
|
"failed to identify client with the server, expected response with OpCode 2 Identified"
|
||||||
|
)
|
||||||
|
return response["d"]
|
||||||
except json.decoder.JSONDecodeError:
|
except json.decoder.JSONDecodeError:
|
||||||
raise OBSSDKError("failed to identify client with the server")
|
raise OBSSDKError(
|
||||||
|
"failed to identify client with the server, please check connection settings"
|
||||||
|
)
|
||||||
|
|
||||||
def req(self, req_type, req_data=None):
|
def req(self, req_type, req_data=None):
|
||||||
payload = {
|
payload = {
|
||||||
|
@ -7,7 +7,7 @@ from websocket import WebSocketTimeoutException
|
|||||||
|
|
||||||
from .baseclient import ObsClient
|
from .baseclient import ObsClient
|
||||||
from .callback import Callback
|
from .callback import Callback
|
||||||
from .error import OBSSDKTimeoutError
|
from .error import OBSSDKError, OBSSDKTimeoutError
|
||||||
from .subs import Subs
|
from .subs import Subs
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -27,8 +27,14 @@ class EventClient:
|
|||||||
defaultkwargs = {"subs": Subs.LOW_VOLUME}
|
defaultkwargs = {"subs": Subs.LOW_VOLUME}
|
||||||
kwargs = defaultkwargs | kwargs
|
kwargs = defaultkwargs | kwargs
|
||||||
self.base_client = ObsClient(**kwargs)
|
self.base_client = ObsClient(**kwargs)
|
||||||
if self.base_client.authenticate():
|
try:
|
||||||
self.logger.info(f"Successfully identified {self} with the server")
|
success = self.base_client.authenticate()
|
||||||
|
self.logger.info(
|
||||||
|
f"Successfully identified {self} with the server using RPC version:{success['negotiatedRpcVersion']}"
|
||||||
|
)
|
||||||
|
except OBSSDKError as e:
|
||||||
|
self.logger.error(f"{type(e).__name__}: {e}")
|
||||||
|
raise
|
||||||
self.callback = Callback()
|
self.callback = Callback()
|
||||||
self.subscribe()
|
self.subscribe()
|
||||||
|
|
||||||
|
@ -17,8 +17,14 @@ class ReqClient:
|
|||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.logger = logger.getChild(self.__class__.__name__)
|
self.logger = logger.getChild(self.__class__.__name__)
|
||||||
self.base_client = ObsClient(**kwargs)
|
self.base_client = ObsClient(**kwargs)
|
||||||
if self.base_client.authenticate():
|
try:
|
||||||
self.logger.info(f"Successfully identified {self} with the server")
|
success = self.base_client.authenticate()
|
||||||
|
self.logger.info(
|
||||||
|
f"Successfully identified {self} with the server using RPC version:{success['negotiatedRpcVersion']}"
|
||||||
|
)
|
||||||
|
except OBSSDKError as e:
|
||||||
|
self.logger.error(f"{type(e).__name__}: {e}")
|
||||||
|
raise
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return self
|
return self
|
||||||
|
@ -1 +1 @@
|
|||||||
version = "1.5.1"
|
version = "1.5.2"
|
||||||
|
Loading…
Reference in New Issue
Block a user