MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / _send_admin_message

Method _send_admin_message

unity_cli/client.py:420–449  ·  view source on GitHub ↗

Send an admin message (LIST_INSTANCES, SET_DEFAULT) without retry. Args: message: Message dict to send. Returns: Response dict from relay server. Raises: ConnectionError: If cannot connect to relay server. ProtocolError: For

(self, message: dict[str, Any])

Source from the content-addressed store, hash-verified

418 self._version_info_called = True
419
420 def _send_admin_message(self, message: dict[str, Any]) -> dict[str, Any]:
421 """Send an admin message (LIST_INSTANCES, SET_DEFAULT) without retry.
422
423 Args:
424 message: Message dict to send.
425
426 Returns:
427 Response dict from relay server.
428
429 Raises:
430 ConnectionError: If cannot connect to relay server.
431 ProtocolError: For protocol errors.
432 """
433 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
434
435 try:
436 try:
437 sock.settimeout(self.timeout)
438 sock.connect((self.host, self.port))
439 except OSError as e:
440 raise ConnectionError(
441 f"Cannot connect to Relay Server at {self.host}:{self.port}",
442 "CONNECTION_FAILED",
443 ) from e
444
445 self._write_frame(sock, message)
446 return self._read_frame(sock)
447
448 finally:
449 sock.close()
450
451 def list_instances(self) -> list[dict[str, Any]]:
452 """List all connected Unity instances.

Callers 2

list_instancesMethod · 0.95
set_default_instanceMethod · 0.95

Calls 3

_write_frameMethod · 0.95
_read_frameMethod · 0.95
ConnectionErrorClass · 0.90

Tested by

no test coverage detected