On Mon, 2003-12-29 at 23:49, Robert Hinn wrote: > Rasmus Agerholm schrieb: > > The RemoteAspect (and the ChangeList) are there to handle the > > replication for you with something like > > > > Sending side: > > > > RemoteAspect *aspect; > > Connection *connection; > > ...setup connection... > > aspect->sendSync(*connection, Thread::getCurrentChangeList()); > > connection->flush(); > > > > Receiving side: > > > > RemoteAspect *aspect; > > Connection *connection; > > ...setup connection... > > connection->selectChannel(); > > aspect->receiveSync(*connection); > > I read in the documentation that the connection->selectChannel() call > locks the channel for exclusive read. Do I have to unlock it again > manually? Or does the flush() operation do that? (In that case I would > have to add a connection->flush() after the aspect->receiveSync(...))
flush() flushes the sending buffer. Thus makes sure that you actually send the data. Equivalent to cout.flush(), when writing to the screen! > > I tried putting > aspect->sendSync(*connection, Thread::getCurrentChangeList()); > connection->flush(); > Thread::getCurrentChangeList()->clearAll(); > in the display callback method (GLUT) of my scene server (which hosts > the scene that the clients want to render), and > connection->selectChannel(); > aspect->receiveSync(*connection); > mgr->redraw(); > Thread::getCurrentChangeList()->clearAll(); > glutSwapBuffers(); > in the display callback of my client. > > However, this doesn't seem to work yet. I get lots of "LOG: > BinaryDataHandler ReadError: read got 0 bytes!" (this occurs on the > aspect->receiveSync(*connection) call in the client display loop), and > the client doesn't seem to get the scene data. Just remembered: You need to have the following call before the osgInit call to enable the use of the changelist: ChangeList::setReadWriteDefault(); You can also have a look at the testRemoteAspect.cpp file. It inspired me quite a lot on the use of RemoteAspect :-) Furthermore the connection have some semafore-like functionality with the wait() and signal() calls, that might be helpful (see their use in OSGMultiDisplayWindow.cpp in the server- and clientSwap() methods. > I read a VRML scene from a file, and added it to my scene graph between > beginEditCP() and endEditCP() calls in my server (before setting up the > connection, but also before clearing the change list). I also tried > adding objects (torus) to the scene on the server during runtime (using > a keyboard callback), also between beginEditCP() and endEditCP() calls, > but the client doesn't seem to get those changes... > > > > Be ware of your begin-/endEdit calls, since only changes made in between > > these will be replicated! > > I've got begin-/endEditCP calls around all my scene graph changes on the > server side, but how does the RemoteAspect know where to apply those > changes? The changes are recorded in the changelist, which you then send through the connection via the RemoteAspect. And the receiving RemoteAspect do the exact same changes on it's scenegraph. > I mean, I create a node (which my SimpleSceneManagers use as > root) in both server and client via Node::create(), but how does the > RemoteAspect know these are my root nodes? It doesn't!!! You shouldn't create a root node on the receiving side. After a succesfull sync, you have the full scene graph at the receiving side. Then you'll have to figure out how to get hold of the root node. You could use the registerCreated function to get hold of a node (any node will do), and then use getParent to do a backward traversal until there is no parent. Then that node must be the root. I haven't done this, so you're on your own here... take a look at the testRemoteAspect.cpp file! Hope it helps /Rasmus -- Rasmus Agerholm Research Assistant VR Media Lab (+45) 9635 8792 Niels Jernes Vej 14 DK-9220 Aalborg Phone: (+45) 9635 8784 Fax: (+45) 9815 2444 http://www.vrmedialab.dk/~rasta ------------------------------------------------------- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click _______________________________________________ Opensg-users mailing list Opensg-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensg-users