WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-16-2005, 02:06 PM
shai shai is offline
Member
 
Join Date: Oct 2004
Posts: 29
general question about <network>.send()

Hello,

I succeeded in sending a list of primitives, i.e., a list of characters, or a list of integers. but i'm running into problems sending a list of objects.

for example, is it possible for me to send:

class People_cfg(object):
def __init__(self):
self.active=0
self.name=""
self.sex="f"
self.headsindex=0
self.clothesindex=0

config_array = []
for i in range(6):
config_array.append(People_cfg())

clients[clientnum].send("connected",config_array)


.......

if so, what 'code' is needed to be written into recieving side (because usually way doesn't work... i.e., "newvar=message[3]")

thanks,
Shai
Reply With Quote
  #2  
Old 08-16-2005, 02:26 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

To send objects across the network you will need to use the Python pickle module. This module will serialize any object into a string, and can recreate it. Here is some code that will take an object and serialize it to a string:
Code:
import pickle
s = pickle.dumps(obj)
The following code will convert a pickle string into an object:
Code:
import pickle
obj = pickle.loads(s)
Let me know if you need more help
Reply With Quote
  #3  
Old 08-16-2005, 04:04 PM
shai shai is offline
Member
 
Join Date: Oct 2004
Posts: 29
nice trick, worked!
thanks
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 10:27 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC