def execute(self, context): assert not share_data.client.current_room share_data.set_dirty() props = get_mixer_props() room_index = props.room_index room = props.rooms[room_index].name logger.warning(f"JoinRoomOperator.execute({room})") room_attributes = get_selected_room_dict() logger.warning( f"Client Blender version: {room_attributes.get(RoomAttributes.BLENDER_VERSION, '')}" ) logger.warning( f"Client Mixer version: {room_attributes.get(RoomAttributes.MIXER_VERSION, '')}" ) clear_undo_history() mixer_prefs = get_mixer_prefs() shared_folders = [] for item in mixer_prefs.shared_folders: shared_folders.append(item.shared_folder) join_room( room, not room_attributes.get(RoomAttributes.GENERIC_PROTOCOL, True), shared_folders, mixer_prefs.ignore_version_check, ) return {"FINISHED"}
def join_room(room_name: str = "mixer_unittest", experimental_sync: bool = False): from mixer.connection import join_room from mixer.broadcaster.common import RoomAttributes from mixer.share_data import share_data from mixer.blender_client.client import clear_scene_content import sys import time # prevent sending our contents in case of cross join. Easier to diagnose the problem clear_scene_content() start = time.monotonic() max_wait = 30 def wait_joinable(): share_data.client.send_list_rooms() joinable = False while not joinable and time.monotonic() - start < max_wait: time.sleep(0.1) share_data.client.fetch_incoming_commands() room_attributes = share_data.client.rooms_attributes.get(room_name) if room_attributes is not None: joinable = room_attributes.get(RoomAttributes.JOINABLE, False) return room_attributes is not None and room_attributes.get( RoomAttributes.JOINABLE, False) if wait_joinable(): join_room(room_name, experimental_sync) else: print(f"ERROR: Cannot join room after {max_wait} seconds. Abort") time.sleep(5) sys.exit(1)
def execute(self, context): bpy.data.window_managers["WinMan"].mixer.send_base_meshes = False mixer_prefs = get_mixer_prefs() if not share_data.client.current_room: try: connect() except Exception as e: self.report({"ERROR"}, f"vrtist.launch connect error : {e}") return {"CANCELLED"} join_room(mixer_prefs.room, mixer_prefs.experimental) args = [ mixer_prefs.VRtist, "--room", share_data.client.current_room, "--hostname", mixer_prefs.host, "--port", str(mixer_prefs.port), "--master", str(share_data.client.client_id), ] subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False) return {"FINISHED"}
def execute(self, context): assert share_data.client.current_room is None if not is_client_connected(): return {"CANCELLED"} join_room(get_mixer_prefs().room) return {"FINISHED"}
def execute(self, context): assert not share_data.client.current_room share_data.set_dirty() props = get_mixer_props() room_index = props.room_index room = props.rooms[room_index].name join_room(room) return {"FINISHED"}
def execute(self, context): assert share_data.client.current_room is None if not is_client_connected(): return {"CANCELLED"} prefs = get_mixer_prefs() room = prefs.room logger.warning(f"CreateRoomOperator.execute({room})") join_room(room, prefs.experimental_sync) return {"FINISHED"}
def execute(self, context): assert not share_data.client.current_room share_data.set_dirty() props = get_mixer_props() room_index = props.room_index room = props.rooms[room_index].name experimental_sync = get_mixer_prefs().experimental_sync logger.warning(f"JoinRoomOperator.execute({room})") join_room(room, experimental_sync) return {"FINISHED"}
def execute(self, context): assert not share_data.client.current_room share_data.set_dirty() props = get_mixer_props() room_index = props.room_index room = props.rooms[room_index].name logger.warning(f"JoinRoomOperator.execute({room})") prefs = get_mixer_prefs() join_room(room, prefs.vrtist_protocol) return {"FINISHED"}
def execute(self, context): bpy.data.window_managers["WinMan"].mixer.send_base_meshes = False mixer_prefs = get_mixer_prefs() if not share_data.client or not share_data.client.current_room: try: connect() except Exception as e: self.report({"ERROR"}, f"vrtist.launch connect error : {e!r}") return {"CANCELLED"} logger.warning("LaunchVRtistOperator.execute({mixer_prefs.room})") join_room(mixer_prefs.room, mixer_prefs.experimental) color = share_data.client.clients_attributes[ share_data.client.client_id].get(ClientAttributes.USERCOLOR, (0.0, 0.0, 0.0)) color = (int(c * 255) for c in color) color = "#" + "".join(f"{c:02x}" for c in color) name = "VR " + share_data.client.clients_attributes[ share_data.client.client_id].get(ClientAttributes.USERNAME, "client") args = [ mixer_prefs.VRtist, "--room", share_data.client.current_room, "--hostname", mixer_prefs.host, "--port", str(mixer_prefs.port), "--master", str(share_data.client.client_id), "--usercolor", color, "--username", name, ] subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False) return {"FINISHED"}
def execute(self, context): bpy.data.window_managers["WinMan"].mixer.send_base_meshes = False mixer_prefs = get_mixer_prefs() if not share_data.client.current_room: if not connect(): return {"CANCELLED"} join_room(mixer_prefs.room) args = [ mixer_prefs.VRtist, "--room", share_data.client.current_room, "--hostname", mixer_prefs.host, "--port", str(mixer_prefs.port), ] subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False) return {"FINISHED"}
def join_room(room_name: str = "mixer_unittest"): from mixer.connection import join_room join_room(room_name)
def execute(self, context): bpy.data.window_managers["WinMan"].mixer.send_bake_meshes = True mixer_prefs = get_mixer_prefs() if not share_data.client or not share_data.client.current_room: timeout = 10 try: connect() except Exception as e: self.report({"ERROR"}, f"vrtist.launch connect error : {e!r}") return {"CANCELLED"} # Wait for local server creation while timeout > 0 and not is_client_connected(): time.sleep(0.5) timeout -= 0.5 if timeout <= 0: self.report({"ERROR"}, "vrtist.launch connect error : unable to connect") return {"CANCELLED"} logger.warning("LaunchVRtistOperator.execute({mixer_prefs.room})") shared_folders = [] for item in mixer_prefs.shared_folders: shared_folders.append(item.shared_folder) mixer_prefs.ignore_version_check = True join_room(mixer_prefs.room, True, shared_folders, mixer_prefs.ignore_version_check) # Wait for room creation/join timeout = 10 while timeout > 0 and share_data.client.current_room is None: time.sleep(0.5) timeout -= 0.5 if timeout <= 0: self.report( {"ERROR"}, "vrtist.launch connect error : unable to join room") return {"CANCELLED"} # Wait for client id timeout = 10 while timeout > 0 and share_data.client.client_id is None: network_consumer_timer() time.sleep(0.1) timeout -= 0.1 if timeout <= 0: self.report({ "ERROR" }, "vrtist.launch connect error : unable to retrieve client id" ) return {"CANCELLED"} color = share_data.client.clients_attributes[ share_data.client.client_id].get(ClientAttributes.USERCOLOR, (0.0, 0.0, 0.0)) color = (int(c * 255) for c in color) color = "#" + "".join(f"{c:02x}" for c in color) name = "VR " + share_data.client.clients_attributes[ share_data.client.client_id].get(ClientAttributes.USERNAME, "client") args = [ mixer_prefs.VRtist, "--room", share_data.client.current_room, "--hostname", mixer_prefs.host, "--port", str(mixer_prefs.port), "--master", str(share_data.client.client_id), "--usercolor", color, "--username", name, "--startScene", os.path.split(bpy.data.filepath)[1], ] LaunchVRtistOperator.vrtist_process = subprocess.Popen( args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False) return {"FINISHED"}
def join_room(room_name: str = "mixer_unittest", experimental_sync: bool = False): from mixer.connection import join_room join_room(room_name, experimental_sync)
def create_room(room_name: str = "mixer_unittest", vrtist_protocol: bool = False): from mixer.connection import join_room join_room(room_name, vrtist_protocol)