summaryrefslogtreecommitdiff
path: root/testIvy.cxx
blob: 53d83d8315f85d5c0eedc66857aabb878a624834 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 *	Ivy probe
 *
 *	Copyright (C) 1997-1999
 *	Centre d'Études de la Navigation Aérienne
 *
 * 	Main and only file
 *
 *	Authors: François-Régis Colin <colin@cenatoulouse.dgac.fr>
 *
 *	$Id$
 * 
 *	Please refer to file version.h for the
 *	copyright notice regarding this software
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <sys/time.h>
#include <unistd.h>
#include <X11/Intrinsic.h>
#include "Ivy.h"
#include "IvyApplication.h"


class IvyTest : public IvyApplicationCallback, public IvyMessageCallback {
public:
	Ivy *bus;
	void Start();
	void OnApplicationConnected(IvyApplication *app);
	void OnApplicationDisconnected(IvyApplication *app);
	void OnMessage(IvyApplication *app, int argc, const char **argv);
	IvyTest();
};
IvyTest :: IvyTest()
{
}
void IvyTest :: Start()
{
	bus = new Ivy( "TestIvy", "TestIvy READY", this );
	bus->BindMsg( "(.*)", this );
	bus->start(NULL);
}
void IvyTest :: OnMessage(IvyApplication *app, int argc, const char **argv)
{
	int i;
	printf ("%s sent ",app->GetName());
	for  (i = 0; i < argc; i++)
			printf(" '%s'",argv[i]);
	printf("\n");
}
void IvyTest :: OnApplicationConnected (IvyApplication *app)
{
	const char *appname;
	const char *host;
	appname = app->GetName();
	host = app->GetHost();

	printf("%s connected from %s\n", appname,  host);

}
void IvyTest :: OnApplicationDisconnected (IvyApplication *app)
{
	const char *appname;
	const char *host;
	appname = app->GetName ();
	host = app->GetHost();

	printf("%s disconnected from %s\n", appname,  host);
}

int main(int argc, char *argv[])
{
        XtAppContext cntx = XtCreateApplicationContext();
        IvyTest test;
	test.bus->setXtAppContext(cntx);
	
	test.Start();

	XtAppMainLoop (cntx);

	return 0;
}