Skip to content
Jiri Hnidek edited this page May 14, 2014 · 5 revisions

Class VerseSession Contains information about corresponding connection to Verse server. It also contains references at all VerseNodes shared at Verse server. First of all you have to connect to Verse server. Then you have to call periodically function session.callback_update():

import vrsent, time
session = vrsent.VerseSession(hostname='localhost', service='12345')
while(session.state != 'DISCONNECTED'):
    session.callback_update()
    time.sleep(1.0/session.fps)

or you can create session object with argument callback_thread=True and previous never ending loop will be called automatically in separate thread. You can use python as Verse client CLI:

import vrsent
# callback_update() method will be called in separate thread
session = vrsent.VerseSession(hostname='localhost', service='12345', \
    callback_thread=True, \
    username='joe', password='pass')

Verse Nodes

All nodes are shared in dictionary session.nodes. If you want to print all VerseNode shared at Verse server, then you can do it with following code:

for node in session.nodes.values():
    print(node)

The output of previous code will look like this:

VerseNode, id: 0, owner_id: 100, parent_id: None, prio: 128, locked: False, custom_type: 0
VerseNode, id: 1, owner_id: 100, parent_id: 0, prio: 128, locked: False, custom_type: 1
VerseNode, id: 2, owner_id: 100, parent_id: 0, prio: 128, locked: False, custom_type: 2
VerseNode, id: 3, owner_id: 100, parent_id: 0, prio: 128, locked: False, custom_type: 3
User (100): Super User
Avatar (65537): Rachel Green@[::ffff:127.0.0.1] ( )
User (1000): Rachel Green
User (1001): Monica Geller
VerseNode, id: 65538, owner_id: 100, parent_id: 65537, prio: 128, locked: False, custom_type: 5
User (65535): Other Users

Why can we see users and avatars in previous output? We have to aware two things. First: Verse server creates automatically special nodes representing users and connected avatars; second: VerseUser and VerseAvatar are subclasses of VerseNode and thus instances of users and avatars are stored in dictionary of VerseNodes.

Verse Users

All users are stored in dictionary session.users. If you want to print all user with account at Verse server, then you can do it with following code:

for user in session.users.values():
    print(user)

Verse Avatars

All connected avatars are stored in dictionary session.avatars. If you want to print all connected avatars to Verse server, then you can do it with following code:

for avatar in session.avatars.values():
    print(avatar)

Debug Prints

If you want to see debug print about received messages, then session.debug_print has to be True.

State of Connection

A session connection: self.state could be in several states:

  • 'CONNECTING'
  • 'CONNECTED'
  • 'DISCONNECTING'
  • 'DISCONNECTED'

FPS Property

A session has fps property. It could be used for getting current negotiated FPS: cur_fps = session.fps. This property has also setter that could be used for negotiating of current FPS: session.fps = new_fps

Clone this wiki locally