This repository was archived by the owner on Dec 25, 2025. It is now read-only.
forked from zoboff/pyVideoSDK
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutils.py
More file actions
36 lines (30 loc) · 1.4 KB
/
utils.py
File metadata and controls
36 lines (30 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import requests
import logging
from logging import Logger
CONFIG_JSON_URL = "http://{}:{}/public/default/config.json"
DEFAULT_WEBSOCKET_PORT = 8765
DEFAULT_HTTP_PORT = 8766
def getHttpPort(ip: str, room_port: int, logger: Logger) -> int:
"""Get the current HTTP TrueConf Room or VideoSDK port. The TrueConf Room or VideoSDK application must be launched"""
try:
json_file = requests.get(url=CONFIG_JSON_URL.format(ip, room_port))
data = json_file.json()
port = data["config"]["http"]["port"]
#logger.info(f'HTTP port: {port}')
except Exception as e:
port = DEFAULT_HTTP_PORT
#logger.warning(f'Failed to fetch HTTP port: {e}')
#logger.warning(f'Set HTTP port to default: {port}')
return port
def getWebsocketPort(ip: str, room_port: int, logger: Logger) -> int:
"""Get the current websocket TrueConf Room or VideoSDK port. The TrueConf Room or VideoSDK application must be launched"""
try:
json_file = requests.get(url=CONFIG_JSON_URL.format(ip, room_port))
data = json_file.json()
port = data["config"]["websocket"]["port"]
#logger.info(f'WebSocket port: {port}')
except Exception as e:
port = DEFAULT_WEBSOCKET_PORT
#logger.warning(f'Failed to fetch current websocket port: {e}')
#logger.warning(f'Set WebSocket port to default: {port}')
return port