More work on the ADC client lib.
This commit is contained in:
parent
8592aa80d4
commit
310ddf4e9d
|
@ -230,7 +230,25 @@ static void ADC_client_on_recv_line(struct ADC_client* client, const char* line,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->callback(client, ADC_CLIENT_USER_JOIN, 0);
|
if (adc_msg_has_named_argument(msg, "ID"))
|
||||||
|
{
|
||||||
|
struct ADC_user user;
|
||||||
|
EXTRACT_NAMED_ARG(msg, "NI", user.name);
|
||||||
|
EXTRACT_NAMED_ARG(msg, "DE", user.description);
|
||||||
|
EXTRACT_NAMED_ARG(msg, "VE", user.version);
|
||||||
|
EXTRACT_NAMED_ARG(msg, "ID", user.cid);
|
||||||
|
EXTRACT_NAMED_ARG(msg, "I4", user.address);
|
||||||
|
|
||||||
|
struct ADC_client_callback_data data;
|
||||||
|
data.user = &user;
|
||||||
|
client->callback(client, ADC_CLIENT_USER_JOIN, &data);
|
||||||
|
|
||||||
|
hub_free(user.name);
|
||||||
|
hub_free(user.description);
|
||||||
|
hub_free(user.version);
|
||||||
|
hub_free(user.cid);
|
||||||
|
hub_free(user.address);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,16 +76,26 @@ struct ADC_chat_message
|
||||||
int flags;
|
int flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ADC_user
|
||||||
|
{
|
||||||
|
sid_t sid;
|
||||||
|
char* cid;
|
||||||
|
char* name;
|
||||||
|
char* description;
|
||||||
|
char* address;
|
||||||
|
char* version;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct ADC_client_callback_data
|
struct ADC_client_callback_data
|
||||||
{
|
{
|
||||||
union {
|
union {
|
||||||
struct ADC_hub_info* hubinfo;
|
struct ADC_hub_info* hubinfo;
|
||||||
struct ADC_chat_message* chat;
|
struct ADC_chat_message* chat;
|
||||||
|
struct ADC_user* user;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef int (*adc_client_cb)(struct ADC_client*, enum ADC_client_callback_type, struct ADC_client_callback_data* data);
|
typedef int (*adc_client_cb)(struct ADC_client*, enum ADC_client_callback_type, struct ADC_client_callback_data* data);
|
||||||
|
|
||||||
struct ADC_client
|
struct ADC_client
|
||||||
|
@ -101,7 +111,6 @@ struct ADC_client
|
||||||
size_t timeout;
|
size_t timeout;
|
||||||
struct net_connection* con;
|
struct net_connection* con;
|
||||||
struct net_timer* timer;
|
struct net_timer* timer;
|
||||||
|
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
char* hub_address;
|
char* hub_address;
|
||||||
char* nick;
|
char* nick;
|
||||||
|
|
|
@ -40,9 +40,11 @@ static int handle(struct ADC_client* client, enum ADC_client_callback_type type,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ADC_CLIENT_USER_JOIN:
|
case ADC_CLIENT_USER_JOIN:
|
||||||
|
printf(" JOIN: %s\n", data->user->name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ADC_CLIENT_USER_QUIT:
|
case ADC_CLIENT_USER_QUIT:
|
||||||
|
printf(" QUIT\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ADC_CLIENT_SEARCH_REQ:
|
case ADC_CLIENT_SEARCH_REQ:
|
||||||
|
|
Loading…
Reference in New Issue