feat: factory setup

This commit is contained in:
Swann Martinez 2019-08-05 18:14:05 +02:00
parent 11b6866045
commit e376650df2
No known key found for this signature in database
GPG Key ID: 414CCAFD8DA720E1
2 changed files with 21 additions and 13 deletions

@ -1 +1 @@
Subproject commit 130845f74dc59d2bb0e5fee8c66e199ac377cff0 Subproject commit e3de7fbfb9758fd576eba3a87d4a8c418066f16c

View File

@ -17,6 +17,7 @@ from pathlib import Path
from . import environment, presence, ui, utils from . import environment, presence, ui, utils
from .libs import umsgpack from .libs import umsgpack
from .libs.replication.client import Client from .libs.replication.client import Client
from .libs.replication.data import ReplicatedDataFactory
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -116,9 +117,8 @@ def unregister_ticks():
except: except:
pass pass
# OPERATORS # OPERATORS
class SessionStartOperator(bpy.types.Operator): class SessionStartOperator(bpy.types.Operator):
bl_idname = "session.start" bl_idname = "session.start"
bl_label = "start" bl_label = "start"
@ -142,20 +142,28 @@ class SessionStartOperator(bpy.types.Operator):
if settings.start_empty: if settings.start_empty:
clean_scene() clean_scene()
# Session setup # Setup data factory
if settings.username == "DefaultUser": bpy_factory = ReplicatedDataFactory()
settings.username = "{}_{}".format(
settings.username, utils.random_string_digits())
# Setup client
client = Client() client = Client(factory=bpy_factory)
client.connect(settings.username,
settings.ip, if self.host:
settings.port) client.host(
id=settings.username,
address=settings.ip,
port=settings.port
)
else:
client.connect(
id=settings.username,
address=settings.ip,
port=settings.port
)
# settings.is_running = True # settings.is_running = True
# bpy.ops.session.refresh() # bpy.ops.session.refresh()
register_ticks() #register_ticks()
# Launch drawing module # Launch drawing module
if settings.enable_presence: if settings.enable_presence: