コード例 #1
0
void GroupMessagingService::run()
{
    routing_table_ =
            sg::Service::instance()->getModulesManager().getModuleInterface<common::RoutingTable>(
                    "routing");

    // stubs
    sg::Stubs stubs(getServiceType());

    boost::shared_ptr<sg::WorkersPool> login_pool =
            getWorkersPoolsManager().registerPool<sg::SingleThreadStrategy>("login");

    stubs.registerMethod<methods::MethodOpen>(login_pool);
    stubs.registerMethod<methods::MethodClose>(login_pool);
    stubs.registerMethod<methods::MethodDropGrp>(login_pool);
    stubs.registerMethod<methods::MethodDropMember>(login_pool);
    stubs.registerMethod<methods::MethodAddMember>(login_pool);
    stubs.registerMethod<methods::MethodSetMemberRoleLevel>();
    stubs.registerMethod<methods::MethodGetOnlineMembersCount>(sg::Stubs::MethodAccessAllowAll);
    stubs.registerMethod<methods::MethodSendGrpChatMsg>(sg::Stubs::MethodAccessAllowAll);
    stubs.registerMethod<methods::MethodAckGrpChatMsg>(sg::Stubs::MethodAccessAllowClient);
    stubs.registerMethod<methods::MethodSendGrpSysMsg>(sg::Stubs::MethodAccessAllowOtherDomain);
    stubs.registerMethod<methods::MethodAckGrpSysMsg>(sg::Stubs::MethodAccessAllowClient);

    getRoutingTable()->startRoutingT<sg::ConnectionHandler>(stubs);


    LOG(info, "\n\n====== server start ("
            << getServiceType() << "_" << getServiceNumber() << "@" << getServiceDomain()
            << ") ======\n\n");
    waitForShutdown();
}
コード例 #2
0
ファイル: apns_test_service.cpp プロジェクト: haoustc/server1
void APNsTestService::run()
{
    routing_table_ = sg::Service::instance()->getModulesManager().getModuleInterface<common::RoutingTable>(
                  "routing");
    
    sg::Stubs stubs(getServiceType());

    routing_table_->startRoutingT<sg::ConnectionHandler>(stubs); 

    LOG(info, "\n\n====== server start ("
             << getServiceType() << "_" << getServiceNumber() << "@" << getServiceDomain()
             << ") ======\n\n");
}
コード例 #3
0
ファイル: service.cpp プロジェクト: zsummer/breeze
bool Service::finishLoad()
{
    setStatus(SS_WORKING);
    if (!isShell())
    {
       if (true)
       {
           LoadServiceNotice notice;
           notice.shellServiceInfos.push_back(ServiceInfo(
               getServiceDockerID(),
               getServiceType(),
               getServiceID(),
               getServiceName(),
               getStatus(),
               getClientDockerID(),
               getClientSessionID()));
           Docker::getRef().broadcastToDockers(notice, false);
       }

        if (getServiceTrait(getServiceType()) == STrait_Multi)
        {
            RefreshServiceToMgrNotice refreshNotice;
            refreshNotice.shellServiceInfos.push_back(ServiceInfo(
                getServiceDockerID(),
                getServiceType(),
                getServiceID(),
                getServiceName(),
                getStatus(),
                getClientDockerID(),
                getClientSessionID()));

            for (auto sd : ServiceDepends)
            {
                if (getServiceTrait(sd.first) == STrait_Single )
                {
                    toService(sd.first, refreshNotice, nullptr);
                }
            }
        }

        LOGI(*this << "local service finish load. service=" << getServiceName() << ", id=" << getServiceID());
    }
    else
    {
        LOGI(*this << "remote service finish load. service=" << getServiceName() << ", id=" << getServiceID());
    }
    
    return true;
}
コード例 #4
0
void MessagesStorageService::run()
{
    // stubs
    sg::Stubs stubs(getServiceType(),
            getWorkersPoolsManager().registerPool<sg::UnorderedThreadPoolStrategy>("roam", 8));

    sg::Service::instance()->getModulesManager().getModuleInterface<common::RoutingTable>(
                        "routing")->startRoutingT<sg::ConnectionHandler>(
                        		stubs);


    LOG(info, "\n\n====== server start ("
            << getServiceType() << "_" << getServiceNumber() << "@" << getServiceDomain()
            << ") ======\n\n");
    waitForShutdown();
}
コード例 #5
0
ファイル: page.cpp プロジェクト: tucci69/tcp_ssl
void CPage::checkForErrors(ConnectionPtr connection)
{
	Trace("checkForErrors", getURL().c_str(), getOverallResultCode());

	// only report an error if page failed and not a benchmark and IS a normal page
	if ((getOverallResultCode() != SC_HEADER_RESULT_SUCCESS) &&
		(getOverallResultCode() != SC_HEADER_RESULT_DUMMY_TRANSACTION) &&
		(getPageType() != SC_WEBPAGE_TYPE_COMP) && // this is not a benchmark competitor page type
		(getOverallResultCode() != SC_HEADER_RESULT_WE_ARE_DOWN)) // don't report our down errors
	{
		// increment the failed page counter
		incrementPagesInError();

		checkErrorsAlertable(connection);

		// decide if we need to send an alert...
		if (isErrorAlertable())
		{
			if ((getPageStatus() != SC_WEBPAGE_STATUS_NO_EMAIL) &&
				(getServiceType() != SC_SERVICE_BENCHMARK))
			{
				// an email is required
				sm_emailRequired = true;
			}
		}
	}
}
コード例 #6
0
void CZapitChannel::dumpServiceXml(FILE * fd, const char * action)
{
	if(action) {
		fprintf(fd, "\t\t\t<S action=\"%s\" i=\"%04x\" n=\"%s\" t=\"%x\" s=\"%d\" num=\"%d\" f=\"%d\"/>\n", action,
				getServiceId(), convert_UTF8_To_UTF8_XML(name.c_str()).c_str(),
				getServiceType(), scrambled, number, flags);

	} else if(getPidsFlag()) {
		fprintf(fd, "\t\t\t<S i=\"%04x\" n=\"%s\" v=\"%x\" a=\"%x\" p=\"%x\" pmt=\"%x\" tx=\"%x\" t=\"%x\" vt=\"%d\" s=\"%d\" num=\"%d\" f=\"%d\"/>\n",
				getServiceId(), convert_UTF8_To_UTF8_XML(name.c_str()).c_str(),
				getVideoPid(), getPreAudioPid(),
				getPcrPid(), getPmtPid(), getTeletextPid(),
				getServiceType(true), type, scrambled, number, flags);
	} else {
		fprintf(fd, "\t\t\t<S i=\"%04x\" n=\"%s\" t=\"%x\" s=\"%d\" num=\"%d\" f=\"%d\"/>\n",
				getServiceId(), convert_UTF8_To_UTF8_XML(name.c_str()).c_str(),
				getServiceType(true), scrambled, number, flags);
	}
}
コード例 #7
0
ファイル: service.cpp プロジェクト: zsummer/breeze
void Service::toDocker(DockerID dockerID, const char * block, unsigned int len)
{
    OutOfBand oob;
    if (getServiceType() == STAvatar)
    {
        oob.clientDockerID = getClientDockerID();
        oob.clientSessionID = getClientSessionID();
        oob.clientAvatarID = getServiceID();
    }
    toDocker(dockerID, oob, block, len);
}
コード例 #8
0
ファイル: service.cpp プロジェクト: zsummer/breeze
void Service::toService(ServiceType serviceType, const char * block, unsigned int len, ServiceCallback cb)
{
    OutOfBand oob;
    if (getServiceType() == STAvatar)
    {
        oob.clientDockerID = getClientDockerID();
        oob.clientSessionID = getClientSessionID();
        oob.clientAvatarID = getServiceID();
    }
    toService(serviceType, InvalidServiceID, oob, block, len, cb);
}
コード例 #9
0
ファイル: service.cpp プロジェクト: zsummer/breeze
bool Service::finishUnload()
{
    setStatus(SS_DESTROY);
    if (!isShell())
    {
        if (getServiceTrait(getServiceType()) == STrait_Multi)
        {
            RefreshServiceToMgrNotice refreshNotice;
            refreshNotice.shellServiceInfos.push_back(ServiceInfo(
                getServiceDockerID(),
                getServiceType(),
                getServiceID(),
                getServiceName(),
                getStatus(),
                getClientDockerID(),
                getClientSessionID()));
            for (auto sd : ServiceDepends)
            {
                if (getServiceTrait(sd.first) == STrait_Single)
                {
                    toService(sd.first, refreshNotice, nullptr);
                }
            }
        }

        UnloadedServiceNotice notice(getServiceType(), getServiceID());
        Docker::getRef().broadcastToDockers(notice, true);
        LOGI(*this << "local service finish unload. service=" << getServiceName() << ", id=" << getServiceID());
    }
    else
    {
        LOGI(*this << "remote service finish unload. service=" << getServiceName() << ", id=" << getServiceID());
    }
    for (auto tID : _repeatTimers)
    {
        SessionManager::getRef().cancelTimer(tID);
    }
    _repeatTimers.clear();
    return true;
}
コード例 #10
0
ファイル: service.cpp プロジェクト: zsummer/breeze
void Service::toDocker(DockerID dockerID, const OutOfBand & oob, const char * block, unsigned int len)
{
    Tracing trc;
    trc.routing.fromServiceType = getServiceType();
    trc.routing.fromServiceID = getServiceID();
    trc.routing.traceID = 0;
    trc.routing.traceBackID = 0;
    trc.routing.toServiceType = STClient;
    trc.routing.toServiceID = InvalidServiceID;
    trc.oob = oob;
    WriteStream ws(ForwardToDocker::getProtoID());
    ws << trc;
    ws.appendOriginalData(block, len);
    Docker::getRef().sendViaDockerID(dockerID, ws.getStream(), ws.getStreamLen());
}
コード例 #11
0
ファイル: service.cpp プロジェクト: zsummer/breeze
void Service::backToService(const Tracing & trace, const char * block, unsigned int len, ServiceCallback cb)
{
    Tracing trc;
    trc.routing.fromServiceType = getServiceType();
    trc.routing.fromServiceID = getServiceID();
    trc.routing.traceID = 0;
    trc.routing.traceBackID = trace.routing.traceID;
    trc.routing.toServiceType = trace.routing.fromServiceType;
    trc.routing.toServiceID = trace.routing.fromServiceID;
    trc.oob = trace.oob;
    if (cb)
    {
        trc.routing.traceID = makeCallback(cb);
    }
    Docker::getRef().toService(trc, block, len, false);
}
コード例 #12
0
ファイル: service.cpp プロジェクト: zsummer/breeze
void Service::directToRealClient(DockerID clientDockerID, SessionID clientSessionID, const char * block, unsigned int len)
{
    if (clientDockerID == ServerConfig::getRef().getDockerID())
    {
        Docker::getRef().sendViaSessionID(clientSessionID, block, len);
        return;
    }
    Tracing trc;
    trc.routing.fromServiceType = getServiceType();
    trc.routing.fromServiceID = getServiceID();
    trc.routing.traceID = 0;
    trc.routing.traceBackID = 0;
    trc.routing.toServiceType = STClient;
    trc.routing.toServiceID = InvalidServiceID;
    trc.oob.clientDockerID = clientDockerID;
    trc.oob.clientSessionID = clientSessionID;
    trc.oob.clientAvatarID = InvalidServiceID;
    Docker::getRef().forwardToRemoteService(trc, block, len);
}
コード例 #13
0
ファイル: service.cpp プロジェクト: zsummer/breeze
void Service::toService(ServiceType serviceType, ServiceID serviceID, const OutOfBand &oob,  const char * block, unsigned int len, ServiceCallback cb)
{
    Tracing trace;
    trace.routing.fromServiceType = getServiceType();
    trace.routing.fromServiceID = getServiceID();
    trace.routing.traceBackID = 0;
    trace.routing.traceID = 0;
    trace.routing.toServiceType = serviceType;
    trace.routing.toServiceID = serviceID;
    trace.oob = oob;
    if (cb)
    {
        trace.routing.traceID = makeCallback(cb);
    }
    if (trace.routing.toServiceType == STClient && trace.routing.toServiceID == InvalidServiceID)
    {
        if ((trace.oob.clientDockerID == InvalidDockerID && trace.oob.clientSessionID != InvalidSessionID) 
            || (trace.oob.clientDockerID != InvalidDockerID && trace.oob.clientSessionID == InvalidSessionID))
        {
            LOGE("toService STClient via session ID but param had some wrong. the condition is clientDockerID and clientSessionID need all valid. trace=" << trace);
            return;
        }
        if (trace.oob.clientDockerID == InvalidDockerID && trace.oob.clientAvatarID == InvalidAvatarID && getServiceType() != STAvatar)
        {
            LOGE("toService STClient but can not get the avatar ID. trace=" << trace << ", this service=" << getServiceType());
            return;
        }
        if (trace.oob.clientDockerID == InvalidDockerID && trace.oob.clientAvatarID == InvalidAvatarID && getServiceType() == STAvatar)
        {
            trace.routing.toServiceID = getServiceID();
        }
        if (trace.oob.clientDockerID == InvalidDockerID && trace.oob.clientAvatarID != InvalidAvatarID)
        {
            trace.routing.toServiceID = trace.oob.clientAvatarID;
        }
    }
    else if (::getServiceTrait(trace.routing.toServiceType) == STrait_Multi && trace.routing.toServiceID == InvalidServiceID)
    {
        LOGE("toService STrait_Multi but can not get the toServiceID. trace=" << trace << ", this service=" << getServiceType());
        return;
    }
    Docker::getRef().toService(trace, block, len, false);
}
コード例 #14
0
void SimulatorService::run()
{
    // push
    auto_ptr<base::net::FilterCreatorStrategyBase> push_ssl_filter;
    string push_pem_file = getProperties().getWithDef<string>("push.pem_file", "");
    push_ssl_filter.reset(new base::net::SSLFilterCreatorStrategy(push_pem_file)); 

    auto_ptr<base::net::HandlerCreatorStrategyBase> push_handler_creator;
    push_handler_creator.reset(new base::net::DefaultHandlerCreatorStrategyT<PushHandler>());

    base::net::Acceptor push_acceptor(getCommunicator().reactor(), base::net::OPT_NODELAY);
    push_acceptor.open(base::net::SockAddr(getProperties().get<string>("push.address")),
            -1, 
            auto_ptr<base::net::HandlerCreatorStrategyBase>(push_handler_creator.release()),
            push_ssl_filter);


    // feedback
    auto_ptr<base::net::FilterCreatorStrategyBase> fb_ssl_filter;
    string fb_pem_file = getProperties().getWithDef<string>("feedback.pem_file", "");
    fb_ssl_filter.reset(new base::net::SSLFilterCreatorStrategy(fb_pem_file)); 

    auto_ptr<base::net::HandlerCreatorStrategyBase> fb_handler_creator;
    fb_handler_creator.reset(new base::net::DefaultHandlerCreatorStrategyT<FeedbackHandler>());

    base::net::Acceptor fb_acceptor(getCommunicator().reactor(), base::net::OPT_NODELAY);
    fb_acceptor.open(base::net::SockAddr(getProperties().get<string>("feedback.address")),
            -1, 
            auto_ptr<base::net::HandlerCreatorStrategyBase>(fb_handler_creator.release()),
            fb_ssl_filter);

    LOG(info, "\n\n====== server start ("
            << getServiceType() << "_" << getServiceNumber() << "@" << getServiceDomain()                                                                                               
            << ") ======\n\n");
    waitForShutdown();
}