2011-12-19 09:54:47 +00:00
|
|
|
/*
|
|
|
|
* uhub - A tiny ADC p2p connection hub
|
|
|
|
* Copyright (C) 2007-2011, Jan Vidar Krey
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
2009-08-28 12:29:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "adcclient.h"
|
|
|
|
|
2009-08-28 16:05:58 +00:00
|
|
|
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;
|
|
|
|
|
2011-11-29 15:39:03 +00:00
|
|
|
case ADC_CLIENT_SSL_HANDSHAKE:
|
|
|
|
puts("*** SSL handshake.");
|
|
|
|
break;
|
|
|
|
|
2009-08-28 16:05:58 +00:00
|
|
|
case ADC_CLIENT_LOGGING_IN:
|
|
|
|
puts("*** Logging in...");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ADC_CLIENT_PASSWORD_REQ:
|
|
|
|
puts("*** Requesting password.");
|
2011-12-09 09:29:50 +00:00
|
|
|
break;
|
2009-08-28 16:05:58 +00:00
|
|
|
|
|
|
|
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:
|
2011-11-30 11:22:59 +00:00
|
|
|
printf(" JOIN: %s %s\n", sid_to_string(data->user->sid), data->user->name);
|
2009-08-28 16:05:58 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ADC_CLIENT_USER_QUIT:
|
2009-10-06 10:39:31 +00:00
|
|
|
printf(" QUIT\n");
|
2009-08-28 16:05:58 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-01-20 16:26:23 +00:00
|
|
|
static int running = 1;
|
2009-08-28 16:05:58 +00:00
|
|
|
|
2009-08-28 12:29:19 +00:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2009-10-06 16:16:38 +00:00
|
|
|
if (argc < 2)
|
|
|
|
{
|
|
|
|
printf("Usage: %s adc[s]://host:port\n", argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-08-28 12:29:19 +00:00
|
|
|
struct ADC_client client;
|
|
|
|
net_initialize();
|
|
|
|
|
|
|
|
ADC_client_create(&client, "uhub-admin", "stresstester");
|
2009-08-28 16:05:58 +00:00
|
|
|
ADC_client_set_callback(&client, handle);
|
2009-10-06 16:16:38 +00:00
|
|
|
ADC_client_connect(&client, argv[1]);
|
2009-08-28 12:29:19 +00:00
|
|
|
|
2011-12-09 09:29:50 +00:00
|
|
|
while (running && net_backend_process()) { }
|
2009-08-28 12:29:19 +00:00
|
|
|
|
|
|
|
ADC_client_destroy(&client);
|
|
|
|
net_destroy();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|