Пример #1
0
void 
UserExit(void)
{
	kill(downloader_pid,SIGINT);
	if( strcmp(log_user, "anonimo") != 0 )
		UserLogout();
}
Пример #2
0
int HandleMessage(MessageType* m, int incomeSd, int userID) 
{
    if (m->type == login) //добавить пользователя и найти ему пару 
    {
        return UserLogin(m, incomeSd, userID);
    }
    else
    if (m->type == logout)
    {   
        return UserLogout(incomeSd, userID);
    }
    if (m->type == disposition)
    {
        return UserDisposition(incomeSd, userID);
    }    
    if (m->type == try_turn)
    {
        return UserTryTurn(incomeSd, userID);
    }
    if (m->type == turn)
    {
        return UserTurn(m, incomeSd, userID);
    }
    return 0;
}
Пример #3
0
client_login_status
UserLogin(char *user, char* passwd)
{
	int ret;
	int ret_code;
	login_t log;
	void *data;
	u_size size;
	
	/* Si estaba logueado con otra cuenta, lo deslogueo */
	if( strcmp(log_user, "anonimo") != 0 )
		UserLogout();
	
	/* Paquete del pedido */
	strcpy(log.user,user);
	strcpy(log.passwd,passwd);
	/* Mando el paquete */
	if( (size=GetLoginData(log, &data)) == -1 )
		return LOGIN_CONNECT_ERROR;
	ret_code = SendRequest(__USER_LOGIN__, 1, data, size);
	free(data);
	/* Proceso la respuesta */
	switch (ret_code) {
		case __LOGIN_OK__: 
		case __USER_IS_LOG__:
			/* Guardo los datos del usuario */
			strcpy(log_user,log.user);
			strcpy(log_passwd,log.passwd);
			ret = USER_LOGIN_OK;
			break;
		case __USER_ERROR__:
			ret = LOGIN_USER_INVALID;
			break;
		case __PASSWD_ERROR__:
			ret = LOGIN_PASS_INVALID;
			break;
		default:
			ret = LOGIN_CONNECT_ERROR;
			break;
	}
		
	return ret;
}