Skip to content

Commit

Permalink
Add some comments to the MVR-xchange code
Browse files Browse the repository at this point in the history
  • Loading branch information
vanous committed Apr 12, 2024
1 parent 15996d6 commit fcceece
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 5 deletions.
6 changes: 3 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,10 +973,10 @@ def onMVR_xchange_enable(self, context):
if not selected_client:
return
DMX_Log.log.debug((selected_client.ip_address, selected_client.station_name))
DMX_MVR_X_Server.enable()
DMX_MVR_X_Server.enable() # start the MVR-xchange TCP server for incoming connections
DMX_MVR_X_Server._instance.server.get_port()
DMX_Zeroconf.enable_server(selected_client.service_name, DMX_MVR_X_Server.get_port())
DMX_MVR_X_Client.join(selected_client)
DMX_Zeroconf.enable_server(selected_client.service_name, DMX_MVR_X_Server.get_port()) # start mdns server and advertise the TCP MVR server
DMX_MVR_X_Client.join(selected_client) # start MVR-xchange client TCP connection and send MVR_JOIN message
else:
DMX_Log.log.info("leave client")
DMX_MVR_X_Client.leave()
Expand Down
5 changes: 3 additions & 2 deletions mdns.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import pathlib

# mdns (zeroconf) instances for discover and for mdns server

class DMX_Zeroconf:
_instance = None
Expand Down Expand Up @@ -48,7 +49,7 @@ def callback(zeroconf: Zeroconf, service_type: str, name: str, state_change: Ser
if b"StationName" in info.properties:
station_name = info.properties[b"StationName"].decode("utf-8")
if b"StationUUID" in info.properties:
station_uuid = info.properties[b"StationUUID"].decode("utf-")
station_uuid = info.properties[b"StationUUID"].decode("utf-8")
station_name = f"{station_name} ({service_name})"
DMX_Log.log.info(info)
if state_change is ServiceStateChange.Added:
Expand Down Expand Up @@ -92,7 +93,7 @@ def enable_server(server_name="test_mvr", port=9999):
addrs = [socket.inet_pton(socket.AF_INET, address) for address in get_all_addresses()]
DMX_Zeroconf._instance.info = ServiceInfo(
"_mvrxchange._tcp.local.",
f"{server_name}._mvrxchange._tcp.local.",
name=f"{server_name}._mvrxchange._tcp.local.",
addresses=addrs,
port=port,
properties=desc,
Expand Down
1 change: 1 addition & 0 deletions mvr_xchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from bpy.props import BoolProperty, CollectionProperty, EnumProperty, IntProperty, StringProperty
from bpy.types import PropertyGroup

# MVR-xchange commit and client RNA structures

class DMX_MVR_Xchange_Commit(PropertyGroup):
def onUpdate(self, context):
Expand Down
7 changes: 7 additions & 0 deletions mvrx_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
from dmx import bl_info as application_info
import uuid as py_uuid

# Instances and callbacks for the MVR TCP client and servers

class DMX_MVR_X_Client:
"""This is a blender specific instance of the MVR-xchange client
(mvrx_protocol-mvrxchange_client-client) TCP connection"""

_instance = None

def __init__(self):
Expand Down Expand Up @@ -136,6 +140,9 @@ def leave():


class DMX_MVR_X_Server:
"""This is an instance of the blender specific mvr_xchange TCP server
(mvrx_protocol-mvrxchange_server-server) for incoming connections"""

_instance = None

def __init__(self):
Expand Down
1 change: 1 addition & 0 deletions mvrxchange/mvr_message.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import struct

# mvr message structures

class mvr_message:
@staticmethod
Expand Down
2 changes: 2 additions & 0 deletions mvrxchange/mvrxchange_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@


class client(Thread):
"""MVR TCP client, it is instanced via blender specific DMX_MVR_X_Client class located in mvrx_protocol.py"""

def __init__(self, ip_address, port, callback, timeout=None, application_uuid=0):
Thread.__init__(self, name=f"client {int(datetime.now().timestamp())}")
DMX_Log.log.debug(self.name)
Expand Down
2 changes: 2 additions & 0 deletions mvrxchange/mvrxchange_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@


class server(Thread):
"""MVR TCP server for incoming connections, it is instanced via blender specific DMX_MVR_X_Server class located in mvrx_protocol.py"""

def __init__(self, callback, uuid=str(uuid4())):
Thread.__init__(self, name=f"server {int(datetime.now().timestamp())}")
DMX_Log.log.debug(self.name)
Expand Down

0 comments on commit fcceece

Please sign in to comment.