mirror of
https://github.com/fastogt/fastocloud_admin.git
synced 2025-03-09 23:38:52 +00:00
Revert
This commit is contained in:
parent
a840fdcfb4
commit
96c043ae02
2 changed files with 17 additions and 45 deletions
|
@ -10,6 +10,13 @@ from gevent import socket
|
|||
from gevent import select
|
||||
|
||||
|
||||
def check_is_auth_client(client) -> bool:
|
||||
if not client:
|
||||
return False
|
||||
|
||||
return client.is_active()
|
||||
|
||||
|
||||
class ServiceManager(IClientHandler):
|
||||
SUBSCRIBER_PORT = 6000
|
||||
BANDWIDTH_PORT = 5000
|
||||
|
@ -105,11 +112,6 @@ class ServiceManager(IClientHandler):
|
|||
pass
|
||||
|
||||
# protected
|
||||
def _check_is_auth_client(self, client) -> bool:
|
||||
if not client:
|
||||
return False
|
||||
|
||||
return client.is_active()
|
||||
|
||||
def _handle_server_ping_command(self, client, resp: Response):
|
||||
pass
|
||||
|
@ -155,7 +157,7 @@ class ServiceManager(IClientHandler):
|
|||
client.device = found_device
|
||||
|
||||
def _handle_get_server_info(self, client, cid: str, params: dict):
|
||||
if not self._check_is_auth_client(client):
|
||||
if not check_is_auth_client(client):
|
||||
client.check_activate_fail(cid, 'User not active')
|
||||
client.disconnect()
|
||||
return
|
||||
|
@ -166,15 +168,16 @@ class ServiceManager(IClientHandler):
|
|||
pass
|
||||
|
||||
def _handle_get_channels(self, client, cid: str, params: dict):
|
||||
if not self._check_is_auth_client(client):
|
||||
if not check_is_auth_client(client):
|
||||
client.check_activate_fail(cid, 'User not active')
|
||||
client.disconnect()
|
||||
return
|
||||
|
||||
client.get_channels_success(cid)
|
||||
channels = client.info.get_streams()
|
||||
client.get_channels_success(cid, channels)
|
||||
|
||||
def _handle_get_runtime_channel_info(self, client, cid: str, params: dict):
|
||||
if not self._check_is_auth_client(client):
|
||||
if not check_is_auth_client(client):
|
||||
client.check_activate_fail(cid, 'User not active')
|
||||
client.disconnect()
|
||||
return
|
||||
|
|
|
@ -3,9 +3,9 @@ from pyfastocloud.subscriber_client import SubscriberClient
|
|||
from pyfastocloud.client import make_utc_timestamp
|
||||
|
||||
|
||||
class SubscriberConnection(object):
|
||||
class SubscriberConnection(SubscriberClient):
|
||||
def __init__(self, sock, addr, handler):
|
||||
self._client = SubscriberClient(sock, addr, handler)
|
||||
super(SubscriberConnection, self).__init__(sock, addr, handler)
|
||||
self._info = None
|
||||
self._current_stream_id = str()
|
||||
self._device = None
|
||||
|
@ -45,44 +45,13 @@ class SubscriberConnection(object):
|
|||
self._last_ping_ts = value
|
||||
|
||||
def recv_data(self) -> bool:
|
||||
data = self._client.read_command()
|
||||
data = self.read_command()
|
||||
if not data:
|
||||
return False
|
||||
|
||||
self._client.process_commands(data)
|
||||
self.process_commands(data)
|
||||
return True
|
||||
|
||||
def socket(self):
|
||||
return self._client.socket()
|
||||
|
||||
def ping(self):
|
||||
return self._client.ping(self._gen_request_id())
|
||||
|
||||
def disconnect(self):
|
||||
return self._client.disconnect()
|
||||
|
||||
def is_active(self):
|
||||
return self._client.is_active()
|
||||
|
||||
def activate_fail(self, cid: str, error: str):
|
||||
return self._client.activate_fail(cid, error)
|
||||
|
||||
def activate_success(self, cid: str):
|
||||
return self._client.activate_success(cid)
|
||||
|
||||
def check_activate_fail(self, command_id: str, error: str):
|
||||
return self._client.check_activate_fail(command_id, error)
|
||||
|
||||
def get_runtime_channel_info_success(self, command_id, sid: str, watchers: int):
|
||||
return self._client.get_runtime_channel_info_success(command_id, sid, watchers)
|
||||
|
||||
def get_channels_success(self, cid: str):
|
||||
channels = self.info.get_streams()
|
||||
return self._client.get_channels_success(cid, channels)
|
||||
|
||||
def get_server_info_success(self, cid: str, bandwidth_host: str):
|
||||
return self._client.get_server_info_success(cid, bandwidth_host)
|
||||
|
||||
# private
|
||||
def _gen_request_id(self) -> int:
|
||||
current_value = self._request_id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue