Skip to content

Commit

Permalink
rm dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Sep 7, 2023
1 parent daf27e3 commit 73fd52b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
2 changes: 1 addition & 1 deletion hivemind_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def main():
service = HiveMindService()
service.start()
service.run()


if __name__ == "__main__":
Expand Down
8 changes: 2 additions & 6 deletions hivemind_core/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,8 @@ class HiveMindListenerProtocol:
mycroft_bus_callback = None # slave asked to inject payload into mycroft bus
shared_bus_callback = None # passive sharing of slave device bus (info)

def bind(self, websocket, bus=None):
def bind(self, websocket, bus):
websocket.protocol = self
if bus is None:
bus = MessageBusClient()
bus.run_in_thread()
bus.connected_event.wait()
self.internal_protocol = HiveMindListenerInternalProtocol(bus)
self.internal_protocol.register_bus_handlers()

Expand Down Expand Up @@ -361,7 +357,7 @@ def handle_handshake_message(self, message: HiveMessage,
# while the access key is transmitted, the password never is
envelope = payload["envelope"]
# TODO - seems tornado never emits these, they never arrive in client
# closing the listener should futures were never awaited
# closing the listener shows futures were never awaited
# until this is debugged force to False
# client.binarize = payload.get("binarize", False)
client.binarize = False
Expand Down
10 changes: 1 addition & 9 deletions hivemind_core/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,13 @@ def on_stopping():
class MessageBusEventHandler(WebSocketHandler):
protocol: Optional[HiveMindListenerProtocol] = None

def __init__(self, application, request, **kwargs):
super().__init__(application, request, **kwargs)
self.emitter = EventEmitter()

@staticmethod
def decode_auth(auth) -> Tuple[str, str]:
userpass_encoded = bytes(auth, encoding="utf-8")
userpass_decoded = base64.b64decode(userpass_encoded).decode("utf-8")
name, key = userpass_decoded.split(":")
return name, key

def on(self, event_name, handler):
self.emitter.on(event_name, handler)

def on_message(self, message):
message = self.client.decode(message)
LOG.info(f"received {self.client.peer} message: {message}")
Expand Down Expand Up @@ -163,7 +156,7 @@ def check_origin(self, origin) -> bool:
return True


class HiveMindService(Thread):
class HiveMindService:
identity = NodeIdentity()

def __init__(self,
Expand All @@ -174,7 +167,6 @@ def __init__(self,
stopping_hook: Callable = on_stopping,
websocket_config: Optional[Dict[str, Any]] = None):

super().__init__()
websocket_config = websocket_config or \
Configuration().get('hivemind_websocket', {})
callbacks = StatusCallbackMap(on_started=started_hook,
Expand Down

0 comments on commit 73fd52b

Please sign in to comment.