WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rating: Thread Rating: 29 votes, 5.00 average. Display Modes
Old 09-13-2010, 04:00 PM
vOliver vOliver is offline
Join Date: Sep 2010
Posts: 6
Problem with server Events

We're having a problem creating a simple server/client model where users log in and they can move around in the same world. We used the duck default model as avatars. I can paste the code in but lets see if i'm missing something obvious

The problem is with the events. Both server and client have the code
SEND ='send')

and I then I do something in the client like

viznet.callback(SEND, update)

and this calls a function that updates the location of all the ducks. The code doesn't work because I never get something sent using the event id SEND for any of the clients. BUT, if I replace SEND with viz.NETWORK_EVENT, everything works as expected. But this is obviously problematic because it triggers on every event, and not all of the events are updates.

I tried printing out the value of UPDATE and its some crazy negative number, however it is the same number on both the server and client.

The relevant client code:
ducks = {}

UPDATE ='update')
SEND ='send')

def sendData():
	global UPDATE
	viznet.client.sendAll(UPDATE, client=viz.getComputerName(), ori = viz.MainView.getEuler(), pos = viz.MainView.getPosition())

def update(e):
	print 'hello'
	if e.client != viz.getComputerName():
		except KeyError:
			ducks[e.client] = viz.add('duck.wrl')


vizact.ontimer(0.1, sendData)
and Server code:

viznet.server.start(port_in=14950, port_out=14951)

ducks = {}

UPDATE ='update')
SEND ='send')

def Update(e):

viz.callback(UPDATE, Update)

def onStartClient(e):
	print '**Client Joined:', e.sender
	ducks[e.sender] = viz.add('duck.wrl')
viz.callback(viznet.CLIENT_CONNECT_EVENT, onStartClient)

def onStopClient(e):
	print '** Client left:', e.sender

viz.callback(viznet.CLIENT_DISCONNECT_EVENT, onStopClient)
Reply With Quote
Old 09-15-2010, 02:14 PM
Gladsomebeast Gladsomebeast is offline
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Not sure whats going on in your code. Must be some bug somewhere that I'm not getting.

This example I worked up does what you want to do (I think):
import viz
import vizact

IS_SERVER = True #change me to False for client
SERVER_NAME = '' #for client, set to network name or IP of server 

import viznet
UPDATE ='update')

	def broadcast():
	def othersend():
		viznet.server.send(OTHER_EVENT,otherMessage='other event')
	vizact.ontimer(1, broadcast)
	vizact.ontimer(3, othersend)
	def onMyEvent(e):
		print 'Received event from server with message:',e.message
	viz.callback(UPDATE, onMyEvent)
	def otherEvent(e):
		print 'Received event from server with message:',e.otherMessage
	viz.callback(OTHER_EVENT, otherEvent)
Paul Elliott
WorldViz LLC
Reply With Quote
Old 09-15-2010, 02:21 PM
Gladsomebeast Gladsomebeast is offline
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Looked at your code a little more...

I'm not seeing any call to viznet.client.send(SEND) or viznet.server.send(SEND) in your code. Thus the viznet.callback(SEND, update) won't get used. In your client code, change to viznet.callback(UPDATE, update) to receive the viznet.client.sendAll(UPDATE) calls the clients make.
Paul Elliott
WorldViz LLC
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Client Server Networking Problem pattie Vizard 12 07-04-2013 09:11 AM
Linking problems with Live Character Frank Verberne Vizard 5 06-04-2008 11:42 AM
Floating license server problems jrodman Vizard 2 10-30-2006 10:39 AM
Intersense Server & 3d Max Hodge1620 Vizard 4 10-26-2005 01:39 PM
problem with female animations vmonkey Vizard 1 10-07-2005 10:36 AM

All times are GMT -7. The time now is 08:15 AM.

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