Пример #1
0
uint cGameWorld::ProcMsg( const sMsg& msg )
{
    switch( msg.m_type )
    {

    case msgFindContainingCell:
        return FindContainingCell( msg.m_pt );

    case msgAddPlayer:
        AddPlayer( msg.m_i[0] );
        return 0;

    case msgRemovePlayer:
        RemovePlayer( msg.m_i[0] );
        return 0;

    case msgAddEnt:
        NotifyAdd(
            (cGameEnt*)MsgDaemon()->Get( msg.m_i[0] ));
        return 0;

    case msgRemoveEnt:
        NotifyRemove(
            (cGameEnt*)MsgDaemon()->Get( msg.m_i[0] ));
        return 0;

    default:
        DP0("Bad Message got to cGameWorld\n");
        return -1;
    }
}
Пример #2
0
void SSDPCache::Add( const QString &sURI,
                     const QString &sUSN,
                     const QString &sLocation,
                     long           sExpiresInSecs )
{    
    // --------------------------------------------------------------
    // Calculate when this cache entry should expire.
    // --------------------------------------------------------------

    TaskTime ttExpires;
    gettimeofday        ( (&ttExpires), NULL );
    AddSecondsToTaskTime(  ttExpires, sExpiresInSecs );

    // --------------------------------------------------------------
    // Get a Pointer to a Entries QDict... (Create if not found)
    // --------------------------------------------------------------

    SSDPCacheEntries *pEntries = Find( sURI );

    if (pEntries == NULL)
    {
        pEntries = new SSDPCacheEntries();
        pEntries->AddRef();
        m_cache.insert( sURI, pEntries );
    }

    pEntries->AddRef();

    // --------------------------------------------------------------
    // See if the Entries Collection contains our USN... (Create if not found)
    // --------------------------------------------------------------

    DeviceLocation *pEntry = pEntries->Find( sUSN );

    if (pEntry == NULL)
    {
        pEntry = new DeviceLocation( sURI, sUSN, sLocation, ttExpires );

        Lock();
        pEntries->Insert( sUSN, pEntry );
        Unlock();

        NotifyAdd( sURI, sUSN, sLocation );
    }
    else
    {
        pEntry->AddRef();
        pEntry->m_sLocation = sLocation;
        pEntry->m_ttExpires = ttExpires;
        pEntry->Release();
    }

    pEntries->Release();
}