• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Sender类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

int main(int argc, char** argv) {
    std::string broker = argc > 1 ? argv[1] : "localhost:5672";
    std::string address = argc > 2 ? argv[2] : "amq.topic";
    Connection connection(broker); 
    try {
        connection.open();
        Session session = connection.createSession();

        Receiver receiver = session.createReceiver(address);
        Sender sender = session.createSender(address);

        sender.send(Message("Hello world!"));

        Message message = receiver.fetch(Duration::SECOND * 1);
        std::cout << message.getContent() << std::endl;
        session.acknowledge();
        
        connection.close();
        return 0;
    } catch(const std::exception& error) {
        std::cerr << error.what() << std::endl;
        connection.close();
        return 1;   
    }
}
开发者ID:yonecle,项目名称:samples,代码行数:25,代码来源:helloworld.cpp


示例2: qpidhello

static int qpidhello(char *br) {
    std::string broker = br ? br : "localhost:5672";
    std::string address = "amq.topic";
    std::string connectionOptions = "";

    Connection connection(broker, connectionOptions);
    try {
        connection.open();
        Session session = connection.createSession();

        Receiver receiver = session.createReceiver(address);
        Sender sender = session.createSender(address);

        sender.send(Message("Hello world!"));

        Message message = receiver.fetch(Duration::SECOND * 1);
        std::cout << message.getContent() << std::endl;
        session.acknowledge();

        connection.close();
        return 0;
    } catch(const std::exception& error) {
        std::cerr << error.what() << std::endl;
        connection.close();
        return 1;
    }
}
开发者ID:AleksandraButrova,项目名称:embox,代码行数:27,代码来源:mainwindow.cpp


示例3: main

int main()
{
  title("Testing Sender package ", '=');

  try
  {
	Sender sender;
    Verbose v(true);
    SocketSystem ss;
    SocketConnecter si;
	Message msg;
    while (!si.connect("localhost", 9085))
    {
      Verbose::show("client waiting to connect");
      ::Sleep(100);
    }
	// TODO sent
	msg.commandType = UPLOAD;
	msg.senderPort = 9080;
	msg.destAdd = "localhost";
	msg.destPort = 9085;
	msg.fileName = "demo.txt";
	sender.sendFiledata(si, msg, true);
	Verbose::show("\n  client calling send shutdown\n");
    si.shutDownSend();
  }
  catch (std::exception& ex)
  {
    Verbose::show("  Exception caught:", always);
    Verbose::show(std::string("\n  ") + ex.what() + "\n\n");
  }
}
开发者ID:saurabhkpatel,项目名称:academic_projects,代码行数:32,代码来源:Sender.cpp


示例4: ACE_TMAIN

int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  if (parse_args (argc, argv) == -1)
    return -1;

  Sender sender;

  Receiver receiver;

  // If passive side
  if (host == 0)
    {
      if (receiver.open_addr (ACE_INET_Addr (port)) == -1)
        return -1;
    }
  // If active side
  else if (sender.open (host, port) == -1)
    return -1;

  for (int success = 1;
       success > 0  && !done;
       )
    // Dispatch events via Proactor singleton.
    success = ACE_Proactor::instance ()->handle_events ();

  return 0;
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:28,代码来源:test_udp_proactor.cpp


示例5: safe_sender

int
Purger_Thread::svc (void)
{
  for (; !this->reactor_.reactor_event_loop_done ();)
    {
      // Get a connection from the cache.
      Sender *sender =
        this->connection_cache_.acquire_connection ();

      // If no connection is available in the cache, sleep for a while.
      if (sender == 0)
        ACE_OS::sleep (ACE_Time_Value (0, 10 * 1000));
      else
        {
          // The reference count on the sender was increased by the
          // cache before it was returned to us.
          ACE_Event_Handler_var safe_sender (sender);

          // Actively close the connection.
          ACE_DEBUG ((LM_DEBUG,
                      "Purger thread calling Sender::close() for handle %d\n",
                      sender->handle_));

          sender->close ();
        }
    }

  return 0;
}
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:29,代码来源:MT_Reference_Counted_Event_Handler_Test.cpp


示例6: downloadMessage

// Function for retreving the content for downloading in client
string Receiver::downloadMessage(string msg1,Message *msgobj,Socket &si)
{
	string msgstr = "";
	Sender sd;
	Message *m = new Message();
	string filename = m->getmsgBody1(msg1), sendaddres = msgobj->getsendAddr(msg1), clientaddres = msgobj->getrecvAddr(msg1);
	string client_port, client_addrs, server_port, server_addrs, parsed, parsed1;
	stringstream input_stringstream1(sendaddres), input_stringstream(clientaddres);

	if (getline(input_stringstream1, parsed, ','))
		client_addrs = parsed;
	if (getline(input_stringstream1, parsed, ' '))
		client_port = parsed;
	if (getline(input_stringstream, parsed1, ','))
		server_addrs = parsed1;
	if (getline(input_stringstream, parsed1, ' '))
		server_port = parsed1;
	int clientport = atoi(client_port.c_str());
	int serverport = atoi(server_port.c_str());
	sd.sendTextFile(client_addrs, clientport, server_addrs, serverport, filename, si, "false");
	Message ackmsg;
	ackmsg.setCommand("Acknowledgement");
	ackmsg.setsendAddr(msgobj->getrecvAddr(msg1));
	ackmsg.setrecAddr(msgobj->getsendAddr(msg1)); 
	string s = "Message :" + msgobj->getmsgBody1(msg1) + "Received by client with address: " + msgobj->getrecvAddr(msg1);
	ackmsg.setmsgBody(s);
    msgstr = ackmsg.getMessage();
	si.sendString(msgstr);
	return msgstr;

}
开发者ID:sdontire,项目名称:Remote-Code-Management-Facility,代码行数:32,代码来源:Receiver.cpp


示例7:

///return 0: succeed  -1: can't found  1: buffer_full
int ClientConnFactoryInnerConnImp2::send_pack(uint64_t connect_id,Sender& s)
{
	DAT* p_dat;
	if(m_connection_map.find_id(connect_id, p_dat)<0)
	{
		return -1;
	}
	try
	{
		uint64_t get_sz=s.headerSize() + s.bodySize();
		p_dat->conn->send(s);
		p_dat->total_write_bytes+=get_sz;
	}
	catch(std::runtime_error& e)
	{
		return 1;
	}
	catch(std::exception& x)
	{
		log(Warn, "ClientConnFactoryInnerConnImp2::send_pack std::exception: %s", x.what());
		disconnect(connect_id);
		return -1;
	}
	return 0;
}
开发者ID:zhangchuhu,项目名称:s2s,代码行数:26,代码来源:ClientConnFactory2.cpp


示例8: Display

void ClientHandler::operator()(Socket& socket_)
{
	Display *disp = new Display();
	BlockingQueue<string> q_;
			while (true)
			{
				Receiver *rs = new Receiver();
				std::string command = socket_.recvString();
				q_.enQ(command);
				if (command.size() == 0)
					break;
				size_t size= q_.size();
				string ackmsg;
				for (size_t i = 0; i < size; i++)
				{
					command = q_.deQ();
					ackmsg = rs->start(command, socket_);
				}
				Sender *s = new Sender();
				if (ackmsg != "")
				{
					s->sendAck(socket_, ackmsg);
				}
		}
  
  disp->show("ClientHandler socket connection closing");
  socket_.shutDown();
  socket_.close();
  disp->show("ClientHandler thread terminating");

}
开发者ID:sdontire,项目名称:Remote-Code-Management-Facility,代码行数:31,代码来源:ServerTest.cpp


示例9: SentFrame

void Mac::SentFrame(bool aAcked)
{
    Address destination;
    Neighbor *neighbor;
    Sender *sender;

    switch (mState)
    {
    case kStateActiveScan:
        mAckTimer.Start(mScanDuration);
        break;

    case kStateTransmitBeacon:
        ScheduleNextTransmission();
        break;

    case kStateTransmitData:
        if (mSendFrame.GetAckRequest() && !aAcked)
        {
            otDumpDebgMac("NO ACK", mSendFrame.GetHeader(), 16);

            if (mTransmitAttempts < kMaxFrameAttempts)
            {
                mTransmitAttempts++;
                StartCsmaBackoff();
                ExitNow();
            }

            mSendFrame.GetDstAddr(destination);

            if ((neighbor = mMle.GetNeighbor(destination)) != NULL)
            {
                neighbor->mState = Neighbor::kStateInvalid;
            }
        }

        mTransmitAttempts = 0;

        sender = mSendHead;
        mSendHead = mSendHead->mNext;

        if (mSendHead == NULL)
        {
            mSendTail = NULL;
        }

        mDataSequence++;
        sender->HandleSentFrame(mSendFrame);

        ScheduleNextTransmission();
        break;

    default:
        assert(false);
        break;
    }

exit:
    {}
}
开发者ID:butterflyy,项目名称:openthread,代码行数:60,代码来源:mac.cpp


示例10: main

//----< Test Stub to test the sender>--------------------------------
int main() {
	title("Message Passing Communication", '=');
	try
	{
		Sender s;
		Verbose v(true);
		SocketSystem ss;
		SocketConnecter si;
		while (!si.connect("localhost", 9080))
		{
			Verbose::show("client waiting to connect");
			::Sleep(100);
		}

		title("Starting string test on client");
		std::vector<std::string> messageDetails;
		messageDetails.push_back("upload");
		messageDetails.push_back("localhost");
		messageDetails.push_back("9080");
		messageDetails.push_back("Delay.pdf");
		messageDetails.push_back("localhost");
		messageDetails.push_back("9081");

		s.clientFileHandling(si, messageDetails, "input/");
		si.shutDownSend();
	}
	catch (std::exception& ex)
	{
		Verbose::show("Exception caught:", always);
		Verbose::show(std::string("\n  ") + ex.what() + "\n\n");
	}
}
开发者ID:bssandeshbs,项目名称:Remote-Message-Passing-Communication,代码行数:33,代码来源:Sender.cpp


示例11: main

int main(int argc, char** argv) {
    const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672";

    try {
        Connection connection = Connection::open(url);
        Session session = connection.newSession();
        Receiver receiver = session.createReceiver("service_queue; {create: always}");

        while (true) {
            Message request = receiver.fetch();
            const Address& address = request.getReplyTo();
            if (address) {
                Sender sender = session.createSender(address);
                std::string s = request.getContent();
                std::transform(s.begin(), s.end(), s.begin(), toupper);
                Message response(s);
                sender.send(response);
                std::cout << "Processed request: " 
                          << request.getContent() 
                          << " -> " 
                          << response.getContent() << std::endl;
                session.acknowledge();
            } else {
                std::cerr << "Error: no reply address specified for request: " << request.getContent() << std::endl;
                session.reject(request);
            }
        }
        connection.close();
        return 0;
    } catch(const std::exception& error) {
        std::cout << error.what() << std::endl;
    }
    return 1;
}
开发者ID:KeithLatteri,项目名称:awips2,代码行数:34,代码来源:server.cpp


示例12: ACE_TMAIN

int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  if (parse_args (argc, argv) == -1)
    return -1;

  Sender sender;

  // Note: acceptor parameterized by the Receiver.
  ACE_Asynch_Acceptor<Receiver> acceptor;

  // If passive side
  if (host == 0)
   {
     if (acceptor.open (ACE_INET_Addr (port),
                        initial_read_size,
                        1) == -1)
       return -1;
   }
  // If active side
  else if (sender.open (host, port) == -1)
    return -1;

  int success = 1;

  while (success > 0  && !done)
    // Dispatch events via Proactor singleton.
    success = ACE_Proactor::instance ()->handle_events ();

  return 0;
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:31,代码来源:test_proactor.cpp


示例13: main

int main()
{
	UserCase* uc = new UserCase;
	UserCase_* uc_ = new UserCase_;
	{
		Sender se;
		se.si.connect(uc, &UserCase::func1);
		se.si.connect(uc, &UserCase::func2);
		se.si.connect(uc_, &UserCase_::func);
		se.si.connect(globalfunc1);
		se.si.connect(globalfunc2);

		se.si.disconnect(globalfunc1);
		delete uc_;

		Signal<float, float, double>::Rv_Vector_Set_Sp ret = se.si(50, 100);
		cout << endl;

		Signal<float, float, double>::Rv_Vector_Set_Sp::const_iterator it = ret.begin();
		Signal<float, float, double>::Rv_Vector_Set_Sp::const_iterator itEnd = ret.end();
		while (it != itEnd)
		{
			cout << "value = "     << (*it)->value     << endl;
			cout << "class_ = "    << (*it)->class_    << endl;
			cout << "function_ = " << (*it)->function_ << endl;
			cout << endl;

			++it;
		}
	}

	delete uc;

	return 0;
}
开发者ID:lexoy,项目名称:signal_slot,代码行数:35,代码来源:main.cpp


示例14: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    Sender sender;
    sender.show();
    return app.exec();
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:7,代码来源:main.cpp


示例15: lansink_poll_revents

int lansink_poll_revents(snd_pcm_ioplug_t *_pPlug, struct pollfd *_pFD, unsigned int _cFDs,
        unsigned short *_pREvents)
{
    Sender *pPlug = (Sender *)_pPlug->private_data;

    try {
        static char buf[1];

        assert(_pFD && _cFDs == 1 && _pREvents);
        *_pREvents = _pFD[0].revents & ~(POLLIN | POLLOUT);

        if (_pFD[0].revents & POLLIN) {
            read(_pFD[0].fd, buf, 1);
            *_pREvents |= POLLOUT;
            pPlug->log.debug("get_delay() = %ld, get_buffer_size() = %lu",
                    pPlug->get_delay(), pPlug->get_buffer_size());
        }

        pPlug->log.debug("%s() = %d, _pFD[0].revents = %d, *_pREvents = %d",
                __FUNCTION__, 0, _pFD[0].revents, *_pREvents);
    } catch (std::exception &e) {
        pPlug->log.error(e.what());
    }

    return 0;
}
开发者ID:NikitaKarnauhov,项目名称:lansink,代码行数:26,代码来源:ioplug.cpp


示例16: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Sender w;
    w.show();

    return a.exec();
}
开发者ID:github-jxm,项目名称:QtCrearor_fast_learn,代码行数:8,代码来源:main.cpp


示例17: main

int main()
{
	Sender s;
	Receiver r(9060);
	Message m;
	m.constructMessage("file_upload", "../Peer/UploadDirectory/test.txt", "localhost", 9050, "localhost", 9060);
	s.postMessage(m);
	return 0;
}
开发者ID:akhilpanchal,项目名称:RemoteCodeManagement,代码行数:9,代码来源:Communication.cpp


示例18: handleBan

void IRCServer::handleBan(Sender sender, const QString &channel, int ban_type, bool apply)
{
    QString nick = (ban_type & BAN_NICK) ? sender.GetNickName() : "*";
    QString user = (ban_type & BAN_USER) ? sender.GetUser() : "*";
    QString host = (ban_type & BAN_HOST) ? sender.GetHost() : "*";
    QString full_ban = nick + IRC::UserPrefix + user + IRC::HostPrefix + host;
    QByteArray command = "MODE " + channel.toUtf8() + " "+ (apply ? "+" : "-") + "b " + full_ban.toUtf8();
    sendCommandAsap(command);
}
开发者ID:jkrecek,项目名称:PirateBot,代码行数:9,代码来源:ircserver.cpp


示例19: test_func

static void test_func(void) {
	test_caseStart("Testing functions");

	{
		Sender<int> s;
		tuple<int> x(2);
		s.subscribe(func_recv(test_func0));
		s.subscribe(bind1_func_recv(2,test_func1));
		s.subscribe(bind1_func_recv(x,test_func2));
		s.subscribe(bind1_func_recv(const_cast<const tuple<int>&>(x),test_func3));
		s.send(1);
		for(size_t i = 0; i <= 3; ++i)
			test_assertSize(calls[i],1);
	}

	{
		Sender<int&> s;
		tuple<int> x(2);
		s.subscribe(func_recv(test_func4));
		s.subscribe(bind1_func_recv(x,test_func5));
		int y = 1;
		s.send(y);
		for(size_t i = 4; i <= 5; ++i)
			test_assertSize(calls[i],1);
	}

	test_caseSucceeded();
}
开发者ID:Logout22,项目名称:Escape,代码行数:28,代码来源:tsubscriber.cpp


示例20: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    Sender sender;
#ifdef Q_OS_SYMBIAN
    sender.showMaximized();
#else
    sender.show();
#endif
    return app.exec();
}
开发者ID:BGmot,项目名称:Qt,代码行数:11,代码来源:main.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Sensor类代码示例发布时间:2022-05-30
下一篇:
C++ SendableChooser类代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap