summaryrefslogtreecommitdiffstats
path: root/bin/test-server.c
blob: 32d27ef9bd9524b97e0235b4b1c185183f7623c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "kiro-camera-server.h"


static KiroContinueFlag
receive_callback (KiroMessageStatus *status, gpointer user_data)
{
    g_message ("Received a message of type: %u", status->message->msg);
    *(gboolean *)user_data = TRUE;
    return KIRO_CALLBACK_CONTINUE;
}


int main (int argc, char **argv)
{
    GError *error = NULL;

    KiroMessenger *messenger = kiro_messenger_new ();

    gboolean flag = FALSE;
    kiro_messenger_add_receive_callback (messenger, receive_callback, &flag);

    gulong rank = 0;
    kiro_messenger_connect (messenger, "127.0.0.1", "60010", &rank, &error);
    if (error) {
        kiro_messenger_free (messenger);
        g_error ("Oh shit! (%s)", error->message);
    }

    while (!flag) {};
    flag = FALSE;


    GVariant *tmp = g_variant_new ("i", UCA_CAMERA_TRIGGER_SOURCE_SOFTWARE);
    gsize data_size = g_variant_get_size (tmp);

    PropUpdate *test = g_malloc0 (sizeof (PropUpdate) + data_size);
    test->id = 11;
    test->type[0] = 'i';
    test->size = data_size;
    g_variant_store (tmp, test->val);
    //g_object_unref (tmp);

    KiroMessage message;
    message.peer_rank = rank;
    message.msg = KIROCS_UPDATE;
    message.payload = test;
    message.size = sizeof (PropUpdate) + data_size;

    kiro_messenger_send_blocking (messenger, &message, &error);
    if (error) {
        kiro_messenger_free (messenger);
        g_error ("Oh shit! (%s)", error->message);
    }

    message.msg = KIROCS_EXIT;
    message.size = 0;
    message.payload = NULL;

    kiro_messenger_send_blocking (messenger, &message, &error);
    if (error) {
        kiro_messenger_free (messenger);
        g_error ("Oh shit! (%s)", error->message);
    }

    kiro_messenger_free (messenger);

    return 0;



}