Exemplo n.º 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();
}
Exemplo n.º 2
0
void rice::pastry::testing::RegrTestApp::forward(::rice::pastry::routing::RouteMessage* rm)
{
    ::rice::pastry::messaging::Message* msg;
    try {
        msg = npc(rm)->unwrap(deserializer);
    } catch (::java::io::IOException* ioe) {
        throw new ::java::lang::RuntimeException(::java::lang::StringBuilder().append(u"Error deserializing message "_j)->append(static_cast< ::java::lang::Object* >(rm))->toString(), ioe);
    }
    auto key = npc(rm)->getTarget();
    auto nextHop = npc(npc(rm)->getNextHop())->getNodeId();
    auto localId = getNodeId();
    auto dist = npc(localId)->distance(key);
    int32_t base = npc(getRoutingTable())->baseBitLength();
    if(npc(prg)->lastMsg == msg) {
        auto localIndex = npc(localId)->indexOfMSDD(key, base);
        auto lastIndex = npc(npc(prg)->lastNode)->indexOfMSDD(key, base);
        if((localIndex > lastIndex && nextHop != localId) || (localIndex == lastIndex && npc(dist)->compareTo(static_cast< ::rice::p2p::commonapi::Id_Distance* >(npc(prg)->lastDist)) > 0))
            npc(::java::lang::System::out())->println(::java::lang::StringBuilder().append(u"at... "_j)->append(static_cast< ::java::lang::Object* >(getNodeId()))
                ->append(u" enrouteMessage failure with "_j)
                ->append(static_cast< ::java::lang::Object* >(msg))
                ->append(u" lastNode="_j)
                ->append(static_cast< ::java::lang::Object* >(npc(prg)->lastNode))
                ->append(u" lastDist="_j)
                ->append(static_cast< ::java::lang::Object* >(npc(prg)->lastDist))
                ->append(u" dist="_j)
                ->append(static_cast< ::java::lang::Object* >(dist))
                ->append(u" nextHop="_j)
                ->append(static_cast< ::java::lang::Object* >(nextHop))
                ->append(u" loci="_j)
                ->append(localIndex)
                ->append(u" lasti="_j)
                ->append(lastIndex)->toString());

        npc(prg)->lastDist = dist;
    }
    npc(prg)->lastMsg = msg;
    npc(prg)->lastDist = dist;
    npc(prg)->lastNode = localId;
}