Beispiel #1
0
void LoginRequest::MergeFrom(const LoginRequest& from) {
  GOOGLE_CHECK_NE(&from, this);
  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
    if (from.has_wb_uuid()) {
      set_wb_uuid(from.wb_uuid());
    }
    if (from.has_channel()) {
      set_channel(from.channel());
    }
    if (from.has_version()) {
      set_version(from.version());
    }
  }
}
Beispiel #2
0
int CliCon::handleLoginRequest(const head& h, const string& req, 
	string& resp){
	TimeRecorder t("CliCon::handleLoginRequest");
	int ret = 0;
	int i = 0;
	LoginRequest lgreq;
	LoginResponse lgresp;	
	string tk;
	string sessid;
	string enctk;

	if(!lgreq.ParseFromArray(req.data(), req.size())){
		ret = INPUT_FORMAT_ERROR;
		goto exit;
	}
	//if login, return the sessid
	if(m_status == STATUS_LOGIN){
		goto exit;
	}

	m_login_time = time(NULL);	
	m_sess.set_id(lgreq.id());
	m_sess.set_type(lgreq.type());
	m_sess.set_consvid(m_serv->getConfig().ID);
	m_sess.set_version(lgreq.version());

	ret = checkType(lgreq.type());

	if(ret < 0){
		ret = INVALID_TYPE;
		goto exit;
	}

	decorationName(m_serv->getConfig().ID, getId(), lgreq.id(), sessid);
	m_sess.set_sessid(sessid);


	for(; i < lgreq.kvs_size(); ++i){
		*(m_sess.add_kvs()) = lgreq.kvs(i);
	}

	if(lgreq.type() > 0){
		TypeMap::addServer(this);
	}
	
	ret = updateSession();

	if(ret < 0){
		ret = CREATE_SESSION_FAIL;
	}
exit:
	if(ret < 0){
		lgresp.set_status(ret);
	}else{
		m_status = STATUS_LOGIN;
		lgresp.set_status(0);
	}

	lgresp.set_sessid(m_sess.sessid());

	lgresp.SerializeToString(&resp);
	ALogError("ConnectServer") << "<action:client_login> <id:" 
		<< m_sess.id() << "> <version:" << lgreq.version() 
		<< "> <type:" << lgreq.type()
		<< "> <token:" << lgreq.token()  
		<< "> <sessid:" << m_sess.sessid() << "> <status:"
		<< ret << "> <errstr:" << getErrStr(ret) << ">";
	return ret;
}