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