[go: up one dir, main page]

File: admin.c

package info (click to toggle)
uhub 0.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,016 kB
  • sloc: ansic: 12,630; xml: 588; sh: 356; perl: 233; makefile: 60
file content (93 lines) | stat: -rw-r--r-- 1,731 bytes parent folder | download
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
88
89
90
91
92
93
/**
 * A remote uhub admin client.
 */

#include "adcclient.h"

static int handle(struct ADC_client* client, enum ADC_client_callback_type type, struct ADC_client_callback_data* data)
{
	switch (type)
	{
		case ADC_CLIENT_CONNECTING:
			puts("*** Connecting...");
			break;

		case ADC_CLIENT_CONNECTED:
			puts("*** Connected.");
			break;

		case ADC_CLIENT_DISCONNECTED:
			puts("*** Disconnected.");
			break;

		case ADC_CLIENT_LOGGING_IN:
			puts("*** Logging in...");
			break;

		case ADC_CLIENT_PASSWORD_REQ:
			puts("*** Requesting password.");

		case ADC_CLIENT_LOGGED_IN:
			puts("*** Logged in.");
			break;

		case ADC_CLIENT_LOGIN_ERROR:
			puts("*** Login error");
			break;

		case ADC_CLIENT_MESSAGE:
			printf("    <%s> %s\n", sid_to_string(data->chat->from_sid), data->chat->message);
			break;

		case ADC_CLIENT_USER_JOIN:
			printf("    JOIN: %s\n", data->user->name);
			break;

		case ADC_CLIENT_USER_QUIT:
			printf("    QUIT\n");
			break;

		case ADC_CLIENT_SEARCH_REQ:
			break;

		case ADC_CLIENT_HUB_INFO:
			printf("    Hub: \"%s\" [%s]\n"
				   "         \"%s\"\n", data->hubinfo->name, data->hubinfo->version, data->hubinfo->description);
			break;

		default:
			printf("Not handled event=%d\n", (int) type);
			return 0;
			break;
	}
	return 1;
}

static int running = 1;

int main(int argc, char** argv)
{
	if (argc < 2)
	{
		printf("Usage: %s adc[s]://host:port\n", argv[0]);
		return 1;
	}

	struct ADC_client client;
	net_initialize();

	ADC_client_create(&client, "uhub-admin", "stresstester");
	ADC_client_set_callback(&client, handle);
	ADC_client_connect(&client, argv[1]);

	while (running)
	{
		net_backend_process();
	}

	ADC_client_destroy(&client);
	net_destroy();
	return 0;
}