Example #1
0
/*
 * Closes the TCP and UDP connections for the client and remove its stuff from
 * the lists.
 */
void disconnect_and_remove_client(uint16_t id, list_t* clients, fd_set* fds)
{
	client_t* c;
	c = list_get(clients, &id);
	if(!c)
		return;
	client_send_goodbye(c);
	if(debug_level >= DEBUG_LEVEL1)
		printf("Client %d disconnected.\n", CLIENT_ID(c));
	client_remove_udp_fd_from_set(c, fds);
	client_remove_tcp_fd_from_set(c, fds);
	client_disconnect_tcp(c);
	client_disconnect_udp(c);
	list_delete(clients, &id);
}
Example #2
0
void disconnect_and_remove_client(list_t *list,client_t *c,fd_set *fds,int full_disconnect)
{
	if(g_debug)
	{
		printf("------> Disconnect and remove Client[%d]\n",c->session_id);
	}

	if(!c || !list)
		return;

	client_remove_tcp_fd_from_set(c,fds);
	/*
	if(g_debug)
	{
		printf("\t remove_fd_from_set\n");
		
	}
	*/
	client_disconnect_tcp(c);
	/*
	if(g_debug)
	{
		printf("\t client_disconnect_tcp\n");
	}
	*/

	if(full_disconnect)
	{
		//本来是想在这里发送关闭消息的
		list_delete(list,c);
		/*
		if(g_debug)
			printf("\t list_delete\n");
		*/
	}
}