本文整理汇总了C++中Subscriber类的典型用法代码示例。如果您正苦于以下问题:C++ Subscriber类的具体用法?C++ Subscriber怎么用?C++ Subscriber使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Subscriber类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scoped
void Searcher::publishCharacters(const std::vector<Filesystem::AbsolutePath> & files){
PaintownUtil::Thread::ScopedLock scoped(subscriptionLock);
for (vector<Subscriber*>::iterator it = subscriptions.begin(); it != subscriptions.end(); it++){
Subscriber * who = *it;
who->receiveCharacters(files);
}
}
示例2: notification
void AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const
{
Subscriber* s = NULL;
Notification notification(Notification::BROADCAST_ACTIVE);
linked_list_search(mSubscribers, (void**)&s, hasSubscriber,
(void*)¬ification, false);
if ((NULL == s) == (GPS_RELEASE_AGPS_DATA_CONN == action)) {
AGpsStatus nifRequest;
nifRequest.size = sizeof(nifRequest);
nifRequest.type = mType;
nifRequest.status = action;
if (s == NULL) {
nifRequest.ipaddr = INADDR_NONE;
memset(&nifRequest.addr, 0, sizeof(nifRequest.addr));
nifRequest.ssid[0] = '\0';
nifRequest.password[0] = '\0';
} else {
s->setIPAddresses(nifRequest.ipaddr,
(char *)&((struct sockaddr_in6*)&(nifRequest.addr))->sin6_addr);
s->setWifiInfo(nifRequest.ssid, nifRequest.password);
}
CALLBACK_LOG_CALLFLOW("agps_cb", %s, loc_get_agps_status_name(action));
(*mServicer)(&nifRequest);
}
示例3: evhttp_send_reply
int Server::sub(struct evhttp_request *req, Subscriber::Type sub_type){
if(evhttp_request_get_command(req) != EVHTTP_REQ_GET){
evhttp_send_reply(req, 405, "Method Not Allowed", NULL);
return 0;
}
bufferevent_enable(req->evcon->bufev, EV_READ);
HttpQuery query(req);
int seq = query.get_int("seq", 0);
int noop = query.get_int("noop", 0);
const char *cb = query.get_str("cb", DEFAULT_JSONP_CALLBACK);
const char *token = query.get_str("token", "");
std::string cname = query.get_str("cname", "");
Channel *channel = this->get_channel_by_name(cname);
if(!channel && this->auth == AUTH_NONE){
channel = this->new_channel(cname);
if(!channel){
evhttp_send_reply(req, 429, "Too Many Channels", NULL);
return 0;
}
}
if(!channel || (this->auth == AUTH_TOKEN && channel->token != token)){
channel->error_token_error(req, cb, token);
return 0;
}
if(channel->subs.size >= ServerConfig::max_subscribers_per_channel){
channel->error_too_many_subscribers(req, cb);
return 0;
}
if(channel->idle < ServerConfig::channel_idles){
channel->idle = ServerConfig::channel_idles;
}
// send buffered messages
if(!channel->msg_list.empty() && channel->seq_next != seq){
//channel->send_old_msgs(req, seq, cb);
//return 0;
}
Subscriber *sub = sub_pool.alloc();
sub->req = req;
sub->serv = this;
sub->type = sub_type;
sub->idle = 0;
sub->seq = seq;
sub->noop_seq = noop;
sub->callback = cb;
channel->add_subscriber(sub);
subscribers ++;
log_debug("%s:%d sub %s, subs: %d, channels: %d",
req->remote_host, req->remote_port,
channel->name.c_str(), channel->subs.size,
used_channels.size);
sub->start();
return 0;
}
示例4: ACE_TMAIN
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
Subscriber subscriber (argc, argv);
subscriber.run ();
}
catch (Subscriber::InitError& ex)
{
std::string& msg = reinterpret_cast<std::string&>(ex);
std::cerr << "Unexpected initialization Error: "
<< msg.c_str() << std::endl;
return -1;
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception (
"ERROR: Subscriber caught exception");
return -1;
}
return 0;
}
示例5: evhttp_send_reply
int Server::sub(struct evhttp_request *req, Subscriber::Type sub_type){
if(evhttp_request_get_command(req) != EVHTTP_REQ_GET){
evhttp_send_reply(req, 405, "Method Not Allowed", NULL);
return 0;
}
HttpQuery query(req);
int seq = query.get_int("seq", 0);
int noop = query.get_int("noop", 0);
const char *cb = query.get_str("cb", "");
const char *token = query.get_str("token", "");
std::string cname = query.get_str("cname", "");
Channel *channel = this->get_channel_by_name(cname);
if(!channel && this->auth == AUTH_NONE){
channel = this->new_channel(cname);
if(!channel){
//evhttp_send_reply(req, 429, "Too many channels", NULL);
Subscriber::send_error_reply(sub_type, req, cb, cname, "429", "Too many channels");
return 0;
}
}
if(!channel || (this->auth == AUTH_TOKEN && channel->token != token)){
//evhttp_send_reply(req, 401, "Token error", NULL);
log_info("%s:%d sub %s, token: %s, token error!",
req->remote_host, req->remote_port, cname.c_str(), token);
Subscriber::send_error_reply(sub_type, req, cb, cname, "401", "Token error");
return 0;
}
if(channel->subs.size >= ServerConfig::max_subscribers_per_channel){
//evhttp_send_reply(req, 429, "Too many subscribers", NULL);
Subscriber::send_error_reply(sub_type, req, cb, cname, "429", "Too many subscribers");
return 0;
}
if(channel->idle < ServerConfig::channel_idles){
channel->idle = ServerConfig::channel_idles;
}
Subscriber *sub = new Subscriber();
sub->req = req;
sub->type = sub_type;
sub->idle = 0;
sub->seq_next = seq;
sub->seq_noop = noop;
sub->callback = cb;
channel->add_subscriber(sub);
subscribers ++;
log_debug("%s:%d sub %s, seq: %d, subs: %d",
req->remote_host, req->remote_port,
channel->name.c_str(), seq, channel->subs.size);
sub->start();
return 0;
}
示例6: main
int main() {
Frame *f = new Frame(1);
Subscriber s;
s.process(f);
f = new SuperFrame(1, 2);
f = new AnotherFrame(1, 2, 3);
s.process(f);
return 0;
}
示例7: main
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
Subscriber subscriber;
subscriber.connectToHost();
Publisher publisher;
publisher.connectToHost();
return app.exec();
}
示例8: Subscriber
/**
* Construct a new subscriber, generate a keypairt and set the required attributes
* @param string node_name name of the subscriber
* @param string port the port number of the subscriber
* @return Subscriber
*/
Subscriber* SecurityServer::addSubscriber(bytestring client_name, std::string port)
{
RSAKeyPair rsa_key_pair = this->generateKeyPair(RSAKeyPair::KeyLength);
this->clients[client_name] = rsa_key_pair.getPublic();
Subscriber *sub = new Subscriber(client_name, port, rsa_key_pair);
sub->setServer(this->key_pair.getPublic());
return sub;
}
示例9: while
void Publisher::publish( Subscriber* pSub, EventNotification* pEvent )
{
Subscriber* pSubscriber = pSub;
// HandleEvent() returns a pointer to the next chained Subscriber, if any.
while ( pSubscriber ) {
pSubscriber = pSubscriber->HandleEvent( pEvent );
}
}
示例10: LOC_LOGD
AgpsState* AgpsReleasedState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
LOC_LOGD("AgpsReleasedState::onRsrcEvent; event:%d\n", (int)event);
if (mStateMachine->hasSubscribers()) {
LOC_LOGE("Error: %s subscriber list not empty!!!", whoami());
// I don't know how to recover from it. I am adding this rather
// for debugging purpose.
}
AgpsState* nextState = this;
switch (event)
{
case RSRC_SUBSCRIBE:
{
// no notification until we get RSRC_GRANTED
// but we need to add subscriber to the list
mStateMachine->addSubscriber((Subscriber*)data);
// request from connecivity service for NIF
//The if condition is added so that if the data call setup fails
//for DS State Machine, we want to retry in released state.
//for AGps State Machine, sendRsrcRequest() will always return success
if(!mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN)) {
// move the state to PENDING
nextState = mPendingState;
}
}
break;
case RSRC_UNSUBSCRIBE:
{
// the list should really be empty, nothing to remove.
// but we might as well just tell the client it is
// unsubscribed. False tolerance, right?
Subscriber* subscriber = (Subscriber*) data;
Notification notification(subscriber, event, false);
subscriber->notifyRsrcStatus(notification);
}
// break;
case RSRC_GRANTED:
case RSRC_RELEASED:
case RSRC_DENIED:
default:
LOC_LOGW("%s: unrecognized event %d", whoami(), event);
// no state change.
break;
}
LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d",
whoami(), nextState->whoami(), event);
return nextState;
}
示例11: on_subscribe
typename std::enable_if<!std::is_same<Subscriber, subscriber<T>>::value, void>::type
on_subscribe(Subscriber o) const {
static_assert(is_subscriber<Subscriber>::value, "on_subscribe must be passed a subscriber.");
ts->on_subscribe(o.as_dynamic());
}
示例12: handle
code handle(std::istream& stream, Subscriber subscriber) const
{
const auto message_ptr = std::make_shared<Message>();
const bool parsed = message_ptr->from_data(stream);
const code ec(parsed ? error::success : error::bad_stream);
subscriber->do_relay(ec, message_ptr);
return ec;
}
示例13: setInput
void TcpDuplexConnection::setInput(Subscriber<Payload>& inputSubscriber) {
inputSubscriber_.reset(&inputSubscriber);
auto* subscription = new MemoryMixin<TcpSubscriptionBase>(*this);
inputSubscriber.onSubscribe(*subscription);
socket_->setReadCB(this);
};
示例14: notify
void Publisher::notify(UpdateData *what)
{
// Kill old subscribers first.
if (this->level == 0) {
for(vector<Subscriber*>::iterator it = this->removableSubscribers.begin(); it != this->removableSubscribers.end(); it++) {
this->subscribers.remove(*it);
}
this->removableSubscribers.clear();
}
// Notify the rest!
this->level++;
for(list<Subscriber*>::iterator it = this->subscribers.begin(); it != this->subscribers.end(); it++) {
Subscriber *subscriber = *it;
if (subscriber != 0) {
subscriber->update(this, what);
}
}
this->level--;
}
示例15: main
/*****************************************************************************************************************************************
Start of main
********************************************************************************************************************************************/
int main(int argc, char** argv){
//init
ros::init(argc, argv, "joystick_to_twist_node");
ROS_INFO_ONCE("ROS is initialized");
Subscriber sub;
//set frame rate for ROS while loop
ros::Rate loop_rate(ROS_FRAME_RATE);
while(ros::ok())
{
sub.sendValue();
ROS_INFO_ONCE("first value is send");
ros::spinOnce();
loop_rate.sleep();
}
return 0;
}