fix(rcf): user data initialisation is now client side

This commit is contained in:
Swann Martinez
2019-04-17 15:01:15 +02:00
parent 214772e9d3
commit 7c354778ce
5 changed files with 34 additions and 16 deletions

View File

@ -256,6 +256,16 @@ def rcf_client_agent(ctx, pipe,queue):
if agent.state == State.SYNCING:
# Store snapshot
if rcfmsg.key == "SNAPSHOT_END":
client_key = "Client/{}".format(agent.id.decode())
client_dict = {}
client_dict['location'] = [[0,0,0],[0,0,0],[0,0,0],[0,0,0]]
client_dict['color'] = [0,1,1,1]
client_dict['active_object'] = ''
client_store = message.RCFMessage(key=client_key, id=agent.id.decode(),body=client_dict)
logger.info(client_store)
client_store.store(agent.property_map)
logger.info("snapshot complete")
agent.state = State.ACTIVE
else:

View File

@ -135,7 +135,7 @@ class HUD(object):
for client in clients:
name = client[0].split('/')[1]
local_username = bpy.context.scene.session_settings.username
if name != local_username:
try:
indices = (
@ -143,8 +143,8 @@ class HUD(object):
)
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
position = client[1][b'location']
color = client[1][b'color']
position = client[1]['location']
color = client[1]['color']
batch = batch_for_shader(
shader, 'LINES', {"pos": position}, indices=indices)

View File

@ -42,7 +42,7 @@ def load(key, value):
load_default(target=target, data=value,
create=True, type=target_type)
elif target_type == 'Client':
pass
load_client(key.split('/')[1],value)
def resolve_bpy_path(path):
@ -60,7 +60,15 @@ def resolve_bpy_path(path):
return item
def load_client(client=None,data=None):
if client and data:
# Draw client
#Load selected object
if data['active_object']:
print("toto")
pass
def load_mesh(target=None, data=None, create=False):
import bmesh

View File

@ -73,8 +73,8 @@ def upload_client_instance_position():
current_coords = draw.get_client_view_rect()
client = client_instance.get(key)
if current_coords != client[0][1][b'location']:
client[0][1][b'location'] = current_coords
if current_coords != client[0][1]['location']:
client[0][1]['location'] = current_coords
client_instance.set(key, client[0][1])
except:
pass

View File

@ -66,18 +66,18 @@ class RCFServerAgent():
request = msg[1]
if request == b"SNAPSHOT_REQUEST":
client_key = "Client/{}".format(identity.decode())
# client_key = "Client/{}".format(identity.decode())
if client_key not in self.property_map.keys():
logger.info("New user:{}".format(identity.decode()))
# if client_key not in self.property_map.keys():
# logger.info("New user:{}".format(identity.decode()))
client_dict = {}
client_dict['location'] = [[0,0,0],[0,0,0],[0,0,0],[0,0,0]]
client_dict['color'] = [0,1,1,1]
client_dict['active_object'] = ''
client_store = message.RCFMessage(key=client_key, id=identity,body=client_dict)
logger.info(client_store)
client_store.store(self.property_map)
# client_dict = {}
# client_dict['location'] = [[0,0,0],[0,0,0],[0,0,0],[0,0,0]]
# client_dict['color'] = [0,1,1,1]
# client_dict['active_object'] = ''
# client_store = message.RCFMessage(key=client_key, id=identity,body=client_dict)
# logger.info(client_store)
# client_store.store(self.property_map)
pass
else:
logger.info("Bad snapshot request")