[Verse-dev] connections on the server

Marcus Hoffmann verse-dev@blender.org
Mon, 28 Jun 2004 10:08:32 +0200


much better... ;)

but every node has in its node head a subscription list... is the
subscription list in vs_connections the one you use for these
node/layer-definitions?
or do you have a global one and link from every node to that?
it's important because i think its usefull to have unique ids for every
subscriber - and that is easier to manage with a global list and links to
that.... just my thoughts... ;)
maybe i can use the connection list as some kind of global subscribers list,
because there are all current subscribers listed with some unique id... or
is it already that way...maybe i missunderstood it...


greets

M

-----Original Message-----
From: verse-dev-admin@blender.org [mailto:verse-dev-admin@blender.org]On
Behalf Of Eskil Steenberg
Sent: Monday, June 28, 2004 2:24 AM
To: verse-dev@blender.org
Subject: Re: [Verse-dev] connections on the server


Hi!/

>you make a connection list and a subsrciption list in connection-storage in
>you server. is the connection list containing all the connected users and
>the subscription list the users that are allowed to change something?
>and what contains the session list in the connection?
>
>
Yes, the first list (VSConnection) is a list of all connected clients. I
use it to cycle through all the connections and listen to their
incoming  commands.

The second structure (VSSubscriptionList) is a structure that can store
subscribers to a specific data element. Whenever a data element is
changed i can go through the list and send out changes to all
subscribing clients

Lets look at some code and see how this code works, lets take a very
commonly used function like callback_send_g_vertex_set_real64_xyz

static void callback_send_g_vertex_set_real64_xyz(void *user, VNodeID
node_id, VLayerID layer_id, uint32 vertex_id, double x, double y, double
z) /* so this is the callback to listen to incoming
verse_send_g_vertex_set_real64_xyz commands*/
{
    VSNodeGeometry *node;
    unsigned int i, count;
    node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); /* get
the node*/
    if(node == NULL) /* does the node exist? */
        return;
    if(layer_id >= node->layer_count || node->layer[layer_id].layer ==
NULL || node->layer[layer_id].type != VN_G_LAYER_VERTEX_XYZ) /* is the
layer id correct?*/
        return;
    if(!vs_b_extend_arrays(node, TRUE, vertex_id)) /*is the vertex id a
ok id that isnt too high?  if the vertex is new, do we need to allocate
more space? if so, then do it */
        return;
    if(((double *)node->layer[0].layer)[vertex_id * 3] == V_REAL64_MAX)
/* is this a new vertex?*/
    {
        for(i = 0; i < node->layer_count; i++) /*If this is a new vertex
set all vertex xyz layers to this position */
        {
            if(node->layer[i].name[0] != 0 && node->layer[i].type ==
VN_G_LAYER_VERTEX_XYZ && node->layer[i].layer != NULL)
            {
                ((double *)node->layer[i].layer)[vertex_id * 3] = x;
/*store the vertex*/
                ((double *)node->layer[i].layer)[vertex_id * 3 + 1] = y;
                ((double *)node->layer[i].layer)[vertex_id * 3 + 2] = z;
            }
        }
        layer_id = 0; /* if it is a new layer send it out as a change
that occurred in layer zero*/
    }else
    {
        ((double *)node->layer[layer_id].layer)[vertex_id * 3] = x;
/*store the vertex*/
        ((double *)node->layer[layer_id].layer)[vertex_id * 3 + 1] = y;
        ((double *)node->layer[layer_id].layer)[vertex_id * 3 + 2] = z;
    }
    count = vs_get_subscript_count(node->layer[layer_id].subscribersd);
/* see how many people subscribe to this layer in 64-bit precision data
format*/
    for(i = 0; i < count; i++) /* cycle all subscribers of the data*/
    {
        vs_set_subscript_session(node->layer[layer_id].subscribersd, i);
/* set the current session to the one of the subscribing client */
        verse_send_g_vertex_set_real64_xyz(node_id, layer_id, vertex_id,
x, y, z); /*send the command*/
    }
    count =
vs_get_subscript_count(node->layer[layer_id].subscribers); /* see how
many people subscribe to this layer in 32-bit precision data format*/
    for(i = 0; i < count; i++) /* cycle all subscribers of the data*/
    {
        vs_set_subscript_session(node->layer[layer_id].subscribers, i);
/* set the current session to the one of the subscribing client */
        verse_send_g_vertex_set_real32_xyz(node_id, layer_id, vertex_id,
(float)x, (float)y, (float)z); /*send the command*/
    }
    vs_reset_subscript_session(); /*reset the current session to the one
who sent the command*/
}

Does this explain it?

Cheers

E
_______________________________________________
Verse-dev mailing list
Verse-dev@blender.org
http://www.blender.org/mailman/listinfo/verse-dev