当前位置: 首页>>代码示例>>C++>>正文


C++ StatusMessage类代码示例

本文整理汇总了C++中StatusMessage的典型用法代码示例。如果您正苦于以下问题:C++ StatusMessage类的具体用法?C++ StatusMessage怎么用?C++ StatusMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了StatusMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

void FileTransfer::Run()
{
  std::cout << "File Transfer service started" << std::endl;

  while (true)
  {
    Command *cmd = DeQ();

    if (cmd == 0) // termination signal
      break;

    if (cmd->Name() == "PutFile")
    {
      PutFile * pf = dynamic_cast<PutFile*>(cmd);

      std::string newpath = _saveDir + "\\" + pf->_fname;
      (void) DeleteFile(newpath.c_str()); // delete target file just in case
      bool status = MoveFile(pf->_path.c_str(), newpath.c_str()) ? true : false;

      StatusMessage * resp = new StatusMessage(status);
      resp->SetConn(cmd->Msg().Conn());
      Dispatch(resp);

    } else
    {
      std::cout << "Command " << cmd->Name() << " is not known" << std::endl;
    }

    delete cmd;
  }

  std::cout << "File Transfer service stopped" << std::endl;
}
开发者ID:jineshkj,项目名称:OOD,代码行数:33,代码来源:FileTransfer.cpp

示例2: family_process

int family_process(const uint64_t ns_id, map<uint64_t, int32_t>& family_map)
{
  const int32_t num = 1000;
  ShowServerInformationMessage msg;
  SSMScanParameter& param = msg.get_param();
  param.type_ = SSM_TYPE_FAMILY;

  param.should_actual_count_ = (num << 16);
  param.end_flag_ = SSM_SCAN_CUTOVER_FLAG_YES;
  //其余,如param.start_next_position_ 等都初始化为0

  while (!((param.end_flag_ >> 4) & SSM_SCAN_END_FLAG_YES))
  {
    param.data_.clear();
    tbnet::Packet*ret_msg = NULL;
    NewClient* client = NewClientManager::get_instance().create_client();
    int ret = send_msg_to_server(ns_id, client, &msg, ret_msg, DEFAULT_NETWORK_CALL_TIMEOUT, true);
    if (TFS_SUCCESS != ret || ret_msg == NULL)
    {
      TBSYS_LOG(ERROR, "get block info error, ret: %d", ret);
      NewClientManager::get_instance().destroy_client(client);
      return EXIT_TFS_ERROR;
    }
    if(ret_msg->getPCode() != SHOW_SERVER_INFORMATION_MESSAGE)
    {
      if (ret_msg->getPCode() == STATUS_MESSAGE)
      {
        StatusMessage* msg = dynamic_cast<StatusMessage*>(ret_msg);
        TBSYS_LOG(ERROR, "get invalid message type: error: %s", msg->get_error());
      }
      TBSYS_LOG(ERROR, "get invalid message type, pcode: %d", ret_msg->getPCode());
      NewClientManager::get_instance().destroy_client(client);
      return EXIT_TFS_ERROR;
    }
    ShowServerInformationMessage* message = dynamic_cast<ShowServerInformationMessage*>(ret_msg);
    SSMScanParameter& ret_param = message->get_param();

    int32_t data_len = ret_param.data_.getDataLen();
    int32_t offset = 0;
    while (data_len > offset)
    {
      FamilyShow family;
      if (TFS_SUCCESS == family.deserialize(ret_param.data_, data_len, offset))
      {
        family_map.insert(make_pair(family.family_id_, family.family_aid_info_));
      }
    }
    param.start_next_position_ = (ret_param.start_next_position_ << 16) & 0xffff0000;
    param.end_flag_ = ret_param.end_flag_;
    if (param.end_flag_ & SSM_SCAN_CUTOVER_FLAG_NO)
    {
      param.addition_param1_ = ret_param.addition_param2_;//next start family_id to scan
    }
    NewClientManager::get_instance().destroy_client(client);
  }
  return TFS_SUCCESS;
}
开发者ID:alimy,项目名称:tfs,代码行数:57,代码来源:stat_main.cpp

示例3: save

void MessageDAO::save(const StatusMessage &statusMsg)
{
    QSettings settings;
    settings.beginGroup(QSETTINGS_MESSAGE_GROUP);
    settings.setValue(STATUS_KEY, statusMsg.status());
    settings.setValue(MESSAGE_KEY, statusMsg.message());
    settings.setValue(CODE_KEY, statusMsg.code());
    settings.endGroup();
}
开发者ID:AnujAroshA,项目名称:Cascades-Samples,代码行数:9,代码来源:MessageDAO.cpp

示例4: parse_command

CliManager::cli_parse_status CliManager::parse_command(std::string command){
	ActionMessage m;
	m.from_string(command);
	StatusMessage response = LocalCommands::parse_local_command(m);
        std::cout << response.to_string() << std::endl;
	if (response.get_status() == "ok"){
		return  PARSE_OK;
	}
	if (response.get_status() == "command"){
		if (response.get<std::string>("action") == "exit"){
				return PARSE_EXIT;
		}
	}
	return PARSE_ERROR;
}
开发者ID:mizobe,项目名称:datad,代码行数:15,代码来源:CliManager.cpp

示例5: command

StatusMessage AsyncRequestClient::send_message(ActionMessage message){
	urdl::istream is;
	is.set_option(urdl::http::request_method("POST"));
	is.set_option(urdl::http::request_content_type("application/x-www-form-urlencoded"));
	is.set_option(urdl::http::request_content(("c=" + message.to_string(max_length)).c_str()));
	is.open("http://" + this -> server + ":8080/command/remote");
	std::string command("");
	std::string output;
	while(is >> output)
		command += output;	
	StatusMessage response;
	response.from_string(command);
        response.put<std::string>("ip-address", this->server);
        return response;
}
开发者ID:mizobe,项目名称:datad,代码行数:15,代码来源:AsyncRequestClient.cpp

示例6: TBSYS_LOG

int TranBlock::write_index()
{
  int ret = TFS_SUCCESS;
  WriteInfoBatchMessage req_wib_msg;
  req_wib_msg.set_block_id(seg_data_.seg_info_.block_id_);
  req_wib_msg.set_offset(0);
  req_wib_msg.set_length(dest_raw_meta_.size());
  req_wib_msg.set_raw_meta_list(&dest_raw_meta_);
  req_wib_msg.set_block_info(&dest_block_info_);
  req_wib_msg.set_cluster(COPY_BETWEEN_CLUSTER);

  NewClient* client = NewClientManager::get_instance().create_client();
  tbnet::Packet* rsp = NULL;
  if(TFS_SUCCESS != send_msg_to_server(dest_ds_id_, client, &req_wib_msg, rsp))
  {
    rsp = NULL;
  }

  if (NULL == rsp)
  {
    TBSYS_LOG(ERROR, "write index failed, blockid: %u, length: %zd, ret: %d",
        seg_data_.seg_info_.block_id_, dest_raw_meta_.size(), ret);
    ret = TFS_ERROR;
  }
  else
  {
    if (STATUS_MESSAGE == rsp->getPCode())
    {
      StatusMessage* sm = dynamic_cast<StatusMessage*>(rsp);
      if (STATUS_MESSAGE_OK != sm->get_status())
      {
        TBSYS_LOG(ERROR, "write raw index to ds: %s fail, blockid: %u, file count: %d, ret: %d",
            tbsys::CNetUtil::addrToString(dest_ds_id_).c_str(), seg_data_.seg_info_.block_id_, static_cast<int32_t>(dest_raw_meta_.size()), sm->get_status());
        ret = TFS_ERROR;
      }
    }
    else
    {
      TBSYS_LOG(ERROR, "write raw index to ds: %s fail, blockid: %u, file count: %d, unkonw msg type",
          tbsys::CNetUtil::addrToString(dest_ds_id_).c_str(), seg_data_.seg_info_.block_id_, static_cast<int32_t>(dest_raw_meta_.size()));
      ret = TFS_ERROR;
    }
  }
  NewClientManager::get_instance().destroy_client(client);

  return ret;
}
开发者ID:0huah0,项目名称:tfs,代码行数:47,代码来源:block_console.cpp

示例7: m

StatusMessage LocalCommands::register_peer(ActionMessage& pt){
	ActionMessage m("register-peer");
	std::string ip_address = pt.get<std::string>("ip-address");
	AsyncRequestClient c(ip_address);
	SerializableList<FileInfo> file_list = ConnectionManager::list_files();
	m.push_back(std::make_pair("file-list", file_list.get_ptree()));
	StatusMessage response = c.send_message(m);
	if (response.get_status() == "ok"){
		if (ConnectionManager::registered_peers.find(response.get_peer_id()) == ConnectionManager::registered_peers.end()){
			ConnectionManager::register_peer(response.get_peer_id(), response.get<std::string>("ip-address"));
			boost::property_tree::ptree ptr = response.get_ptree();
			BOOST_FOREACH(const boost::property_tree::ptree::value_type& child, ptr.get_child("file-list")) {
				boost::shared_ptr<FileInfo> f(new FileInfo);
				f -> from_ptree(child.second.get_child(""));
				ConnectionManager::register_extern_file(f);
			}
		}
	}
开发者ID:mizobe,项目名称:datad,代码行数:18,代码来源:LocalCommands.cpp

示例8: while

void
StatusMessageList::LoadFile(TLineReader &reader)
{
  // Init first entry
  StatusMessage current;
  current.Clear();

  /* Read from the file */
  TCHAR *buffer;
  const TCHAR *key, *value;
  while ((buffer = reader.ReadLine()) != NULL) {
    // Check valid line? If not valid, assume next record (primative, but works ok!)
    if (*buffer == _T('#') || !parse_assignment(buffer, key, value)) {
      // Global counter (only if the last entry had some data)
      if (!current.IsEmpty()) {
        list.append(current);
        current.Clear();

        if (list.full())
          break;
      }
    } else {
      if (_tcscmp(key, _T("key")) == 0) {
        if (current.key == NULL)
          current.key = UnescapeBackslash(value);
      } else if (_tcscmp(key, _T("sound")) == 0) {
        if (current.sound == NULL)
          current.sound = UnescapeBackslash(value);
      } else if (_tcscmp(key, _T("delay")) == 0) {
        TCHAR *endptr;
        unsigned ms = ParseUnsigned(value, &endptr);
        if (endptr > value)
          current.delay_ms = ms;
      } else if (_tcscmp(key, _T("hide")) == 0) {
        if (_tcscmp(value, _T("yes")) == 0)
          current.visible = false;
      }
    }
  }

  if (!current.IsEmpty())
    list.append(current);
}
开发者ID:MindMil,项目名称:XCSoar,代码行数:43,代码来源:StatusMessage.cpp

示例9: StatusMessage

void TextSearch::ProcessCompletedSearch(SearchString *ss)
{
  if (ss->_completed != ss->_jobs)  // ensure all jobs have been completed
    return;

  //std::cout << "Search Completed" << std::endl;

  StatusMessage * resp = new StatusMessage(true);
  resp->SetConn(ss->Msg().Conn());

  std::chrono::milliseconds ms = 
    std::chrono::duration_cast<std::chrono::milliseconds>(resp->CreateTime() - ss->CreateTime());

  resp->AddHeader("ExecutionTime", ms.count());
  while (ss->_matches.size())
  {
    std::string *match = ss->_matches.deQ();
    resp->WriteData(match->c_str(), match->size());
    resp->WriteData("\n", 1);
    delete match;
  }

  Dispatch(resp);

  delete ss;
}
开发者ID:jineshkj,项目名称:OOD,代码行数:26,代码来源:TextSearch.cpp

示例10: rm_no_replicate_block_from_ns

int rm_no_replicate_block_from_ns(const char* ns_addr, const uint64_t block_id)
{
  int ret = TFS_SUCCESS;
  ClientCmdMessage req_cc_msg;
  req_cc_msg.set_cmd(CLIENT_CMD_EXPBLK);
  req_cc_msg.set_value3(block_id);
  req_cc_msg.set_value4(tfs::nameserver::HANDLE_DELETE_BLOCK_FLAG_ONLY_RELATION);

  NewClient* client = NewClientManager::get_instance().create_client();
  tbnet::Packet* rsp = NULL;
  if((ret = send_msg_to_server(Func::get_host_ip(ns_addr), client, &req_cc_msg, rsp)) != TFS_SUCCESS)
  {
    TBSYS_LOG(ERROR, "send remove block from ns command failed. block_id: %" PRI64_PREFIX "u, ret: %d", block_id, ret);
  }
  else
  {
    assert(NULL != rsp);
    if (STATUS_MESSAGE == rsp->getPCode())
    {
      StatusMessage* sm = dynamic_cast<StatusMessage*>(rsp);
      if (STATUS_MESSAGE_OK == sm->get_status())
      {
        TBSYS_LOG(INFO, "remove block from ns success, ns_addr: %s, blockid: %" PRI64_PREFIX "u", ns_addr, block_id);
      }
      else
      {
        TBSYS_LOG(ERROR, "remove block from ns fail, ns_addr: %s, blockid: %" PRI64_PREFIX "u, ret: %d",
            ns_addr, block_id, sm->get_status());
        ret = sm->get_status();
      }
    }
    else
    {
      TBSYS_LOG(ERROR, "remove block from ns: %s fail, blockid: %" PRI64_PREFIX "u, unkonw msg type", ns_addr, block_id);
      ret = EXIT_UNKNOWN_MSGTYPE;
    }
  }
  NewClientManager::get_instance().destroy_client(client);
  return ret;
}
开发者ID:nosqldb,项目名称:tfs,代码行数:40,代码来源:recover_disk_data_to_cluster_v2.cpp

示例11: create_msg_ref

    int OpManager::update_block_info(const BlockInfoV2& block_info, const common::UpdateBlockInfoType type)
    {
      int ret = TFS_SUCCESS;
      DsRuntimeGlobalInformation& ds_info = DsRuntimeGlobalInformation::instance();
      create_msg_ref(UpdateBlockInfoMessageV2, req_msg);
      req_msg.set_block_info(block_info);
      req_msg.set_type(type);
      req_msg.set_server_id(ds_info.information_.id_);

      NewClient* client = NewClientManager::get_instance().create_client();
      if (NULL == client)
      {
        ret = EXIT_CLIENT_MANAGER_CREATE_CLIENT_ERROR;
      }
      else
      {
        tbnet::Packet* ret_msg = NULL;
        ret = send_msg_to_server(ds_info.ns_vip_port_, client, &req_msg, ret_msg);
        if (TFS_SUCCESS == ret)
        {
          if (STATUS_MESSAGE == ret_msg->getPCode())
          {
            StatusMessage* smsg = dynamic_cast<StatusMessage*>(ret_msg);
            ret = smsg->get_status();
            TBSYS_LOG(DEBUG, "update block info. blockid: %"PRI64_PREFIX"u, status: %d %s",
                block_info.block_id_, smsg->get_status(), smsg->get_error());
          }
          else
          {
            ret = EXIT_COMMIT_BLOCK_UPDATE_ERROR;
          }
        }
        NewClientManager::get_instance().destroy_client(client);
      }

      return ret;
    }
开发者ID:alimy,项目名称:tfs,代码行数:37,代码来源:aop_manager.cpp

示例12: while

    int ShowInfo::show_block(const int8_t type, const int32_t num, const uint32_t block_id, const int32_t block_chunk_num, int32_t count, const int32_t interval, const string& filename)
    {
      interrupt_ = false;
      is_loop_ = (count == 0);
      FILE* fp = NULL;
      if (TFS_ERROR == get_file_handle(filename, &fp))
      {
        return TFS_ERROR;
      }

      while ((count > 0 || is_loop_) && !interrupt_)
      {
        StatStruct stat;

        ShowServerInformationMessage msg;
        SSMScanParameter& param = msg.get_param();
        param.type_ = SSM_TYPE_BLOCK;
        param.child_type_ = SSM_CHILD_BLOCK_TYPE_INFO | SSM_CHILD_BLOCK_TYPE_SERVER;

        bool once = false;
        if (block_id > 0)
        {
          param.should_actual_count_ = 0x10000;
          param.end_flag_ = SSM_SCAN_CUTOVER_FLAG_NO;
          param.should_actual_count_ = 0x10000;
          param.start_next_position_ = ((block_id % block_chunk_num) << 16);
          param.addition_param1_ = block_id;
          once = true;
        }
        else
        {
          param.should_actual_count_ = (num << 16);
          param.end_flag_ = SSM_SCAN_CUTOVER_FLAG_YES;
        }

        while ((!((param.end_flag_ >> 4) & SSM_SCAN_END_FLAG_YES)) && !interrupt_)
        {
          param.data_.clear();
          block_set_.clear();
          tbnet::Packet*ret_msg = NULL;
          NewClient* client = NewClientManager::get_instance().create_client();
          int ret = send_msg_to_server(ns_ip_, client, &msg, ret_msg);
          if (TFS_SUCCESS != ret || ret_msg == NULL)
          {
            TBSYS_LOG(ERROR, "get block info error, ret: %d", ret);
            NewClientManager::get_instance().destroy_client(client);
            return TFS_ERROR;
          }
          //TBSYS_LOG(DEBUG, "pCode: %d", ret_msg->get_message_type());
          if(ret_msg->getPCode() != SHOW_SERVER_INFORMATION_MESSAGE)
          {
            if (ret_msg->getPCode() == STATUS_MESSAGE)
            {
              StatusMessage* msg = dynamic_cast<StatusMessage*>(ret_msg);
              TBSYS_LOG(ERROR, "get invalid message type: error: %s", msg->get_error());
            }
            TBSYS_LOG(ERROR, "get invalid message type, pcode: %d", ret_msg->getPCode());
            NewClientManager::get_instance().destroy_client(client);
            return TFS_ERROR;
          }
          ShowServerInformationMessage* message = dynamic_cast<ShowServerInformationMessage*>(ret_msg);
          SSMScanParameter& ret_param = message->get_param();

          int32_t data_len = ret_param.data_.getDataLen();
          int32_t offset = 0;
          if (data_len > 0)
          {
            print_header(BLOCK_TYPE, type, fp);
          }
          while ((data_len > offset) && !interrupt_)
          {
            BlockShow block;
            if (TFS_SUCCESS == block.deserialize(ret_param.data_, data_len, offset, param.child_type_))
            {
              //block.BlockBase::dump();
              if (once && (block.info_.block_id_ != block_id))
              {
                TBSYS_LOG(ERROR, "block(%u)(%u) not exists", block.info_.block_id_, block_id);
                break;
              }
              stat.add(block);
              block_set_.insert(block);
            }
          }
          std::set<BlockShow>::iterator iter = block_set_.begin();
          for (; iter != block_set_.end(); iter++)
          {
             (*iter).dump(type, fp);
          }
          param.start_next_position_ = (ret_param.start_next_position_ << 16) & 0xffff0000;
          param.end_flag_ = ret_param.end_flag_;
          if (param.end_flag_ & SSM_SCAN_CUTOVER_FLAG_NO)
          {
            param.addition_param1_ = ret_param.addition_param2_;
          }
          NewClientManager::get_instance().destroy_client(client);
          if (once)
          {
            break;
          }
//.........这里部分代码省略.........
开发者ID:0huah0,项目名称:tfs,代码行数:101,代码来源:show.cpp

示例13: switch

void *OSDPlugin::processEvent(Event *e)
{
    OSDRequest osd;
    Contact *contact;
    Message *msg;
    OSDUserData *data;
    switch (e->type()){
    case EventContactOnline:
        contact = (Contact*)(e->param());
        if (contact->getIgnore()) break;
        osd.contact = contact->id();
        osd.type    = OSD_ALERTONLINE;
        queue.push_back(osd);
        processQueue();
        break;
    case EventMessageDeleted:
    case EventMessageRead:
    case EventMessageReceived:
        msg = (Message*)(e->param());
        contact = getContacts()->contact(msg->contact());
        if (contact == NULL)
            break;
        data = (OSDUserData*)(contact->getUserData(user_data_id));
        if (data == NULL)
            break;
        osd.contact = msg->contact();
        if (msg->type() == MessageStatus) {
            StatusMessage *smsg = (StatusMessage*)msg;
            switch (smsg->getStatus()) {
            case STATUS_AWAY:
                osd.type = OSD_ALERTAWAY;
                break;
            case STATUS_NA:
                osd.type = OSD_ALERTNA;
                break;
            case STATUS_DND:
                osd.type = OSD_ALERTDND;
                break;
            case 100:    /* STATUS_OCCUPIED, but defined in icqclient.h ! */
                osd.type = OSD_ALERTOCCUPIED;
                break;
            case STATUS_FFC:
                osd.type = OSD_ALERTFFC;
                break;
            case STATUS_OFFLINE:
                osd.type = OSD_ALERTOFFLINE;
                break;
            case STATUS_ONLINE:
                osd.type = OSD_NONE;
                return NULL;
            default:
                log(L_DEBUG,"OSD: Unknown status %ld",smsg->getStatus());
                osd.type = OSD_NONE;
                return NULL;
            }
            queue.push_back(osd);
            processQueue();
        }else{
            osd.type    = OSD_MESSAGE;
            if ((m_request.type == OSD_MESSAGE) && (m_request.contact == msg->contact())){
                queue.push_front(osd);
                m_timer->stop();
                m_timer->start(100);
            }else{
                queue.push_back(osd);
                processQueue();
            }
        }
        break;
    case EventContactStatus:
        contact = (Contact*)(e->param());
        if (contact->getIgnore()) break;
        data = (OSDUserData*)(contact->getUserData(user_data_id));
        if (data){
            unsigned style = 0;
            string wrkIcons;
            const char *statusIcon = NULL;
            contact->contactInfo(style, statusIcon, &wrkIcons);
            bool bTyping = false;
            while (!wrkIcons.empty()){
                if (getToken(wrkIcons, ',') == "typing"){
                    bTyping = true;
                    break;
                }
            }
            if (bTyping){
                list<unsigned>::iterator it;
                for (it = typing.begin(); it != typing.end(); ++it)
                    if ((*it) == contact->id())
                        break;
                if (it == typing.end()){
                    typing.push_back(contact->id());
                    osd.contact = contact->id();
                    osd.type    = OSD_TYPING;
                    queue.push_back(osd);
                    processQueue();
                }
            }else{
                list<unsigned>::iterator it;
                for (it = typing.begin(); it != typing.end(); ++it)
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:sim-im-svn,代码行数:101,代码来源:osd.cpp

示例14: while

void SessionClient::availableMessages()
{
  Message* message;
  while( ( message = receiveMessage() ) != NULL )
  {
    server_->checkSessionStateChange( this, message->type() );

    switch( message->type() )
    {
      case Message::MSG_HELLO:
      {
        // Send the client its initial nickname
        sendMessage( new NicknameMessage( nickName_ ) );
        break;
      }

      case Message::MSG_NICKNAME:
      {
        NicknameMessage* nickNameMessage = dynamic_cast<NicknameMessage*>( message );
        if( ! server_->clientChangedNickName( this, nickNameMessage ) )
        {
          // The nickname could not be changed, report the problem to the client
          sendMessage( new StatusMessage( Errors::Status_NickNameAlreadyRegistered ) );
        }
        else
        {
          // Change the nickname
          setNickName( nickNameMessage->nickName() );
          sendMessage( new NicknameMessage( nickName_ ) );
        }

        break;
      }

      case Message::MSG_STATUS:
      {
        StatusMessage* statusMessage = dynamic_cast<StatusMessage*>( message );
        Common::debug( "The client reports status code %d", statusMessage->statusCode() );

        Errors::StatusCode code = statusMessage->statusCode();
        switch( code )
        {
          case Errors::Status_Ok:
            Common::debug( "Session \"%s\" sent status OK", nickName_ );
            break;

          case Errors::Status_AcceptFileTransfer:
          case Errors::Status_RejectFileTransfer:
            if( ! server_->isFileTransferModeActive() )
            {
              sendMessage( new StatusMessage( Errors::Status_FileTransferCanceled ) );
              break;
            }

            // Save the status
            fileTransferStatus_ = code;

            server_->clientSentFileTransferResponse( this, code == Errors::Status_AcceptFileTransfer );
            break;

          default:
            Common::debug( "Session \"%s\" sent status %d", nickName_, code );
            break;
        }
        break;
      }

      case Message::MSG_CHAT:
      {
        ChatMessage* chatMessage = dynamic_cast<ChatMessage*>( message );
        if( ! server_->clientSentChatMessage( this, chatMessage ) )
        {
          sendMessage( new StatusMessage( Errors::Status_ChattingAlone ) );
        }
        break;
      }

      case Message::MSG_FILE_REQUEST:
      {
        // Deny new file transfers if one is already active
        if( server_->isFileTransferModeActive() )
        {
          sendMessage( new StatusMessage( Errors::Status_FileTransferCanceled ) );
          break;
        }

        FileTransferMessage* fileMessage = dynamic_cast<FileTransferMessage*>( message );
        if( ! server_->clientSentFileTransferRequest( this, fileMessage ) )
        {
          sendMessage( new StatusMessage( Errors::Status_ChattingAlone ) );
          break;
        }

        fileTransferStatus_ = Errors::Status_AcceptFileTransfer;
        break;
      }

      case Message::MSG_FILE_DATA:
      {
        FileDataMessage* dataMessage = dynamic_cast<FileDataMessage*>( message );
//.........这里部分代码省略.........
开发者ID:vpilo,项目名称:tari-exam,代码行数:101,代码来源:sessionclient.cpp

示例15: while

    int ShowInfo::show_family(const int8_t type, const int32_t num, const int64_t family_id, int32_t count, const int32_t interval, const string& filename)
    {
      interrupt_ = false;
      is_loop_ = (count == 0);//count表示循环重复拉取的次数,默认是1,0表示一直按照间间隔循环
      FILE* fp = NULL;
      if (TFS_SUCCESS != get_file_handle(filename, &fp))
      {
        return EXIT_TFS_ERROR;
      }

      while ((count > 0 || is_loop_) && !interrupt_)
      {
        ShowServerInformationMessage msg;
        SSMScanParameter& param = msg.get_param();
        param.type_ = SSM_TYPE_FAMILY;

        uint64_t family_count = 0;
        bool once = false;
        if (family_id > 0)
        {
          param.should_actual_count_ = 0x10000;
          param.end_flag_ = SSM_SCAN_CUTOVER_FLAG_NO;
          param.start_next_position_ = ((family_id % nameserver::MAX_FAMILY_CHUNK_NUM) << 16);
          param.addition_param1_ = family_id;
          once = true;
        }
        else if (family_id == 0)
        {
          if (type & BLOCK_TYPE_SERVER_LIST)
          {
            fprintf(fp, "para error, -s must be used with -d\n");
            put_file_handle(fp);
            return EXIT_PARAMETER_ERROR;
          }
          param.should_actual_count_ = (num << 16);
          param.end_flag_ = SSM_SCAN_CUTOVER_FLAG_YES;
          //其余,如param.start_next_position_ 等都初始化为0
        }
        else
        {
          TBSYS_LOG(ERROR, "get invalid family_id: %"PRI64_PREFIX"d < 0", family_id);
          put_file_handle(fp);
          return EXIT_PARAMETER_ERROR;
        }

        while ((!((param.end_flag_ >> 4) & SSM_SCAN_END_FLAG_YES)) && !interrupt_)
        {
          param.data_.clear();
          tbnet::Packet*ret_msg = NULL;
          NewClient* client = NewClientManager::get_instance().create_client();
          int ret = send_msg_to_server(ns_ip_, client, &msg, ret_msg);
          if (TFS_SUCCESS != ret || ret_msg == NULL)
          {
            TBSYS_LOG(ERROR, "get block info error, ret: %d", ret);
            NewClientManager::get_instance().destroy_client(client);
            put_file_handle(fp);
            return EXIT_TFS_ERROR;
          }
          if(ret_msg->getPCode() != SHOW_SERVER_INFORMATION_MESSAGE)
          {
            if (ret_msg->getPCode() == STATUS_MESSAGE)
            {
              StatusMessage* msg = dynamic_cast<StatusMessage*>(ret_msg);
              TBSYS_LOG(ERROR, "get invalid message type: error: %s", msg->get_error());
            }
            TBSYS_LOG(ERROR, "get invalid message type, pcode: %d", ret_msg->getPCode());
            NewClientManager::get_instance().destroy_client(client);
            put_file_handle(fp);
            return EXIT_TFS_ERROR;
          }
          ShowServerInformationMessage* message = dynamic_cast<ShowServerInformationMessage*>(ret_msg);
          SSMScanParameter& ret_param = message->get_param();

          int32_t data_len = ret_param.data_.getDataLen();
          int32_t offset = 0;
          if (data_len > 0)
          {
            print_header(FAMILY_TYPE, type, fp);
          }
          while ((data_len > offset) && !interrupt_)
          {
            FamilyShow family;
            if (TFS_SUCCESS == family.deserialize(ret_param.data_, data_len, offset))
            {
              if (once && (family.family_id_ != family_id))
              {
                //TBSYS_LOG(ERROR, "only get family: %"PRI64_PREFIX"u, but %"PRI64_PREFIX"u not exists", family.family_id_, family_id);
                break;
              }
              if (once && (type & BLOCK_TYPE_SERVER_LIST))
              {
                ret = family.get_members_ds_list(ns_ip_);
                if (TFS_SUCCESS != ret)
                {
                  put_file_handle(fp);
                  return ret;
                }
              }
              family.dump(type, fp);
              ++family_count;
//.........这里部分代码省略.........
开发者ID:yinzhigang,项目名称:tfs,代码行数:101,代码来源:show.cpp


注:本文中的StatusMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。