View Single Post
  #5  
Old 04-09-2009, 11:27 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
As Jeff pointed out, the message receiver needs to do different things depending on the message type.

For flexibility, try adding a 'messageType' variable to all your <mailbox>.send() calls. That way you can check the 'messageType' in your 'onNetwork' function then access the variables you know come with specific message types.

Code:
CREATE_PERSON_NETWORK_EVENT = 1
UPDATE_PERSON_NETWORK_EVENT = 2

def personJoined():
    mailbox.send(messageType=CREATE_PERSON_NETWORK_EVENT, avatarFileName='blabla.cfg')

def sendPersonData(person):
    mailbox.send(messageType=UPDATE_PERSON_NETWORK_EVENT, euler=...


def onNetwork(e):
    if e.messageType == CREATE_PERSON_NETWORK_EVENT:
        viz.add(e.avatarFileName)
        ....
    elif e.messageType == UPDATE_PERSON_NETWORK_EVENT:
        otherPerson.setEuler(e.euler)
Also, the viznet.py module will help you create more robust networked applications.

Jeff or Farshizo can you post that *sweet* viznet demo with the boxes and springs?
__________________
Paul Elliott
WorldViz LLC
Reply With Quote