Skip to content

Commit

Permalink
Let the OS decide local_addr, and add host argument to connect method
Browse files Browse the repository at this point in the history
This allowed me to run serialosc and pymonome under different docker
containers.
  • Loading branch information
lopter committed Jul 7, 2023
1 parent fc073f3 commit fc708f1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions monome.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ async def connect(self, host, port, loop=None):
loop = asyncio.get_event_loop()

transport, protocol = await loop.create_datagram_endpoint(lambda: self,
local_addr=('127.0.0.1', 0),
remote_addr=(host, port))

def disconnect(self):
Expand Down Expand Up @@ -237,16 +236,16 @@ def connection_made(self, transport):
self.send('/serialosc/list', self.host, self.port)
self.send('/serialosc/notify', self.host, self.port)

async def connect(self, loop=None):
async def connect(self, host='127.0.0.1', loop=None):
if loop is None:
if sys.version_info >= (3, 7):
loop = asyncio.get_running_loop()
else:
loop = asyncio.get_event_loop()

transport, protocol = await loop.create_datagram_endpoint(lambda: self,
local_addr=('127.0.0.1', 0),
remote_addr=('127.0.0.1', 12002))
transport, protocol = await loop.create_datagram_endpoint(
lambda: self, remote_addr=(host, 12002),
)

def _on_serialosc_device(self, addr, path, id, type, port):
type = type.strip() # remove trailing spaces for arcs
Expand Down

0 comments on commit fc708f1

Please sign in to comment.