本文整理汇总了C++中Sender类的典型用法代码示例。如果您正苦于以下问题:C++ Sender类的具体用法?C++ Sender怎么用?C++ Sender使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sender类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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;
}
}
示例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");
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
示例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:
{}
}
示例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");
}
}
示例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;
}
示例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;
}
示例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;
}
示例14: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Sender sender;
sender.show();
return app.exec();
}
示例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;
}