Skip to content

Commit

Permalink
Merge pull request #185 from s0600204/tcp-tuple
Browse files Browse the repository at this point in the history
Expect Dispatcher replies for TCP to be tuples, not lists
  • Loading branch information
attwad authored Jan 4, 2025
2 parents e50f481 + f8244e5 commit b3ebafa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions pythonosc/osc_tcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def handle(self) -> None:
)
# resp = _call_handlers_for_packet(data, self.server.dispatcher)
for r in resp:
if not isinstance(r, list):
if not isinstance(r, tuple):
r = [r]
msg = osc_message_builder.build_msg(r[0], r[1:])
b = struct.pack("!I", len(msg.dgram))
Expand Down Expand Up @@ -117,7 +117,7 @@ def handle(self) -> None:
p, self.client_address
)
for r in resp:
if not isinstance(r, list):
if not isinstance(r, tuple):
r = [r]
msg = osc_message_builder.build_msg(r[0], r[1:])
self.request.sendall(slip.encode(msg.dgram))
Expand Down Expand Up @@ -284,7 +284,7 @@ async def handle1_0(
buf, client_address
)
for r in result:
if not isinstance(r, list):
if not isinstance(r, tuple):
r = [r]
msg = osc_message_builder.build_msg(r[0], r[1:])
b = struct.pack("!I", len(msg.dgram))
Expand Down Expand Up @@ -319,7 +319,7 @@ async def handle_1_1(
p, client_address
)
for r in result:
if not isinstance(r, list):
if not isinstance(r, tuple):
r = [r]
msg = osc_message_builder.build_msg(r[0], r[1:])
writer.write(slip.encode(msg.dgram))
Expand Down
16 changes: 8 additions & 8 deletions pythonosc/test/test_osc_tcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ def respond(*args, **kwargs):

def test_response_with_args(self):
def respond(*args, **kwargs):
return [
return (
"/SYNC",
1,
"2",
3.0,
]
)

self.dispatcher.map("/SYNC", respond)
mock_sock = mock.Mock()
Expand Down Expand Up @@ -208,12 +208,12 @@ def respond(*args, **kwargs):

def test_response_with_args(self):
def respond(*args, **kwargs):
return [
return (
"/SYNC",
1,
"2",
3.0,
]
)

self.dispatcher.map("/SYNC", respond)
mock_sock = mock.Mock()
Expand Down Expand Up @@ -314,12 +314,12 @@ def respond(*args, **kwargs):

async def test_response_with_args(self):
def respond(*args, **kwargs):
return [
return (
"/SYNC",
1,
"2",
3.0,
]
)

self.dispatcher.map("/SYNC", respond)
self.mock_reader.read.side_effect = [_SIMPLE_MSG_NO_PARAMS_1_1, b""]
Expand All @@ -332,12 +332,12 @@ def respond(*args, **kwargs):

async def test_async_response_with_args(self):
async def respond(*args, **kwargs):
return [
return (
"/SYNC",
1,
"2",
3.0,
]
)

self.dispatcher.map("/SYNC", respond)
self.mock_reader.read.side_effect = [_SIMPLE_MSG_NO_PARAMS_1_1, b""]
Expand Down

0 comments on commit b3ebafa

Please sign in to comment.