Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

## [Unreleased]

- Added TCPDispatchClient to tcp_client
- Fixed TPC dispatcher type annotations

## [1.9.3]
Expand Down
19 changes: 19 additions & 0 deletions pythonosc/tcp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,25 @@ def get_messages(self, timeout: int = 30) -> Generator:
r = self.receive(timeout)


class TCPDispatchClient(SimpleTCPClient):
"""OSC TCP Client that includes a :class:`Dispatcher` for handling responses and other messages from the server"""

dispatcher = Dispatcher()

def handle_messages(self, timeout_sec: int = 30) -> None:
"""Wait :int:`timeout` seconds for a message from the server and process each message with the registered
handlers. Continue until a timeout occurs.

Args:
timeout: Time in seconds to wait for a message
"""
r = self.receive(timeout_sec)
while r:
for m in r:
self.dispatcher.call_handlers_for_packet(m, (self.address, self.port))
r = self.receive(timeout_sec)


class AsyncTCPClient:
"""Async OSC client to send :class:`OscMessage` or :class:`OscBundle` via TCP"""

Expand Down