Skip to content

Commit

Permalink
Fix the entity events
Browse files Browse the repository at this point in the history
  • Loading branch information
olijeffers0n committed May 31, 2023
1 parent 7804328 commit 678eb8d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion rustplus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@

__name__ = "rustplus"
__author__ = "olijeffers0n"
__version__ = "5.6.2"
__version__ = "5.6.3"
__support__ = "Discord: https://discord.gg/nQqJe8qvP8"
10 changes: 6 additions & 4 deletions rustplus/api/remote/rust_remote_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from asyncio import Future
from typing import Union, Dict

import betterproto

from .camera.camera_manager import CameraManager
from .events import EventLoopManager, EntityEvent, RegisteredListener
from .rustplus_proto import AppRequest, AppMessage, AppEmpty, AppCameraSubscribe
Expand Down Expand Up @@ -173,7 +175,7 @@ async def get_entity_info(remote: RustRemote, eid):
await remote.api._handle_ratelimit()

app_request: AppRequest = remote.api._generate_protobuf()
app_request.entityId = eid
app_request.entity_id = eid
app_request.get_entity_info = AppEmpty()
app_request.get_entity_info._serialized_on_wire = True

Expand All @@ -182,16 +184,16 @@ async def get_entity_info(remote: RustRemote, eid):
return await remote.get_response(app_request.seq, app_request, False)

def entity_event_callback(future_inner: Future) -> None:
entity_info = future_inner.result()
entity_info: AppMessage = future_inner.result()

if entity_info.response.HasField("error"):
if betterproto.serialized_on_wire(entity_info.response.error):
raise SmartDeviceRegistrationError(
f"Entity: '{entity_id}' has not been found"
)

EntityEvent.handlers.register(
RegisteredListener(
entity_id, (coroutine, entity_info.response.entityInfo.type)
entity_id, (coroutine, entity_info.response.entity_info.type)
),
self.server_id,
)
Expand Down
2 changes: 1 addition & 1 deletion rustplus/api/remote/rustws.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ async def run(self) -> None:
try:
await self.handle_message(app_message)
except Exception:
self.logger.exception("An Error occurred whilst handling the event")
self.logger.exception("An Error occurred whilst handling the message from the server")

async def handle_message(self, app_message: AppMessage) -> None:
if app_message.response.seq in self.remote.ignored_responses:
Expand Down

0 comments on commit 678eb8d

Please sign in to comment.