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


C++ CClient::IsAMaster方法代码示例

本文整理汇总了C++中CClient::IsAMaster方法的典型用法代码示例。如果您正苦于以下问题:C++ CClient::IsAMaster方法的具体用法?C++ CClient::IsAMaster怎么用?C++ CClient::IsAMaster使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CClient的用法示例。


在下文中一共展示了CClient::IsAMaster方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HandleKeepalives

void CDplusProtocol::HandleKeepalives(void)
{
    // send keepalives
    CBuffer keepalive;
    EncodeKeepAlivePacket(&keepalive);
    
    // iterate on clients
    CClients *clients = g_Reflector.GetClients();
    int index = -1;
    CClient *client = NULL;
    while ( (client = clients->FindNextClient(PROTOCOL_DPLUS, &index)) != NULL )
    {
        // send keepalive
        //std::cout << "Sending DPlus packet @ " << client->GetIp() << std::endl;
        m_Socket.Send(keepalive, client->GetIp());
        
        // is this client busy ?
        if ( client->IsAMaster() )
        {
            // yes, just tickle it
            client->Alive();
        }
        // check it's still with us
        else if ( !client->IsAlive() )
        {
            // no, disconnect
            CBuffer disconnect;
            EncodeDisconnectPacket(&disconnect);
            m_Socket.Send(disconnect, client->GetIp());
            
            // and remove it
            std::cout << "DPlus client " << client->GetCallsign() << " keepalive timeout" << std::endl;
            clients->RemoveClient(client);
        }
    }
    g_Reflector.ReleaseClients();
}
开发者ID:,项目名称:,代码行数:37,代码来源:

示例2: HandleQueue

void CDplusProtocol::HandleQueue(void)
{
    m_Queue.Lock();
    while ( !m_Queue.empty() )
    {
        // get the packet
        CPacket *packet = m_Queue.front();
        m_Queue.pop();
        
        // get our sender's id
        int iModId = g_Reflector.GetModuleIndex(packet->GetModuleId());
        
        // check if it's header and update cache
        if ( packet->IsDvHeader() )
        {
            // this relies on queue feeder setting valid module id
            m_DvHeadersCache[iModId] = CDvHeaderPacket((const CDvHeaderPacket &)*packet);
            m_iSeqCounters[iModId] = 0;
        }

        // encode it
        CBuffer buffer;
        if ( EncodeDvPacket(*packet, &buffer) )
        {
            // and push it to all our clients who are not streaming in
            // note that for dplus protocol, all stream of all modules are push to all clients
            // it's client who decide which stream he's interrrested in
            CClients *clients = g_Reflector.GetClients();
            int index = -1;
            CClient *client = NULL;
            while ( (client = clients->FindNextClient(PROTOCOL_DPLUS, &index)) != NULL )
            {
                // is this client busy ?
                if ( !client->IsAMaster() )
                {
                    // check if client is a dextra dongle
                    // then replace RPT2 with XRF instead of REF
                    // if the client type is not yet known, send bothheaders
                    if ( packet->IsDvHeader() )
                    {
                        // sending header in Dplus is client specific
                        SendDvHeader((CDvHeaderPacket *)packet, (CDplusClient *)client);
                    }
                    else if ( packet->IsDvFrame() )
                    {
                        // and send the DV frame
                         m_Socket.Send(buffer, client->GetIp());

                        // is it time to insert a DVheader copy ?
                        if ( (m_iSeqCounters[iModId]++ % 21) == 20 )
                        {
                            // yes, clone it
                            CDvHeaderPacket packet2(m_DvHeadersCache[iModId]);
                            // and send it 
                            SendDvHeader(&packet2, (CDplusClient *)client);
                        }
                    }
                    else
                    {
                        // otherwise, send the original packet
                        m_Socket.Send(buffer, client->GetIp());
                    }
                }
            }
            g_Reflector.ReleaseClients();
        }
        
        
        // done
        delete packet;
    }
    m_Queue.Unlock();
}
开发者ID:,项目名称:,代码行数:73,代码来源:


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