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


C++ Subscriber类代码示例

本文整理汇总了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);
    }
}
开发者ID:MortimerBlater,项目名称:paintown,代码行数:7,代码来源:search.cpp

示例2: notification

void AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const
{
    Subscriber* s = NULL;
    Notification notification(Notification::BROADCAST_ACTIVE);
    linked_list_search(mSubscribers, (void**)&s, hasSubscriber,
                       (void*)&notification, 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);
    }
开发者ID:AndroGeek974,项目名称:android_device_htc_m4,代码行数:27,代码来源:loc_eng_agps.cpp

示例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;
}
开发者ID:changguanghua,项目名称:icomet,代码行数:60,代码来源:server.cpp

示例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;
}
开发者ID:shaominghaoo,项目名称:OpenDDS,代码行数:28,代码来源:subscriber.cpp

示例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;
}
开发者ID:ITSTONE,项目名称:icomet,代码行数:57,代码来源:server.cpp

示例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;
}
开发者ID:madaan,项目名称:entire-src,代码行数:9,代码来源:base_station.cpp

示例7: main

int main(int argc, char** argv)
{
    QCoreApplication app(argc, argv);
    Subscriber subscriber;
    subscriber.connectToHost();
    Publisher publisher;
    publisher.connectToHost();
    return app.exec();
}
开发者ID:ejvr,项目名称:qmqtt,代码行数:9,代码来源:example.cpp

示例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;
    }
开发者ID:ash2005,项目名称:cdax-crypto-cpp,代码行数:15,代码来源:SecurityServer.cpp

示例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 );
    }
}
开发者ID:CodeMonkey1959,项目名称:PubSubsumption,代码行数:9,代码来源:PubSub.cpp

示例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;
}
开发者ID:5idaidai,项目名称:android_device_xiaomi_msm8226-common,代码行数:51,代码来源:loc_eng_agps.cpp

示例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());
    }
开发者ID:CedarLogic,项目名称:RxCpp,代码行数:7,代码来源:rx-test.hpp

示例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;
 }
开发者ID:staring,项目名称:libbitcoin-network,代码行数:8,代码来源:message_subscriber.hpp

示例13: setInput

void TcpDuplexConnection::setInput(Subscriber<Payload>& inputSubscriber) {
  inputSubscriber_.reset(&inputSubscriber);

  auto* subscription = new MemoryMixin<TcpSubscriptionBase>(*this);

  inputSubscriber.onSubscribe(*subscription);

  socket_->setReadCB(this);
};
开发者ID:alexstaytuned,项目名称:reactivesocket-cpp,代码行数:9,代码来源:TcpDuplexConnection.cpp

示例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--;
}
开发者ID:visusnet,项目名称:Blobby-Warriors,代码行数:19,代码来源:PublishSubscribe.cpp

示例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;
}
开发者ID:nfrancke,项目名称:turtle5k_drive_system,代码行数:23,代码来源:joystick_to_twist_node.cpp


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