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


C++ PlayerConnectionPtr类代码示例

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


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

示例1: ModeratorsInGame

bool ServerNetworking::ModeratorsInGame() const {
    for (PlayerConnections::const_iterator it = m_player_connections.begin();
         it != m_player_connections.end(); ++it)
    {
        const PlayerConnectionPtr player = *it;
        if (player->GetClientType() == Networking::CLIENT_TYPE_HUMAN_MODERATOR)
            return true;
    }
    return false;
}
开发者ID:Ablu,项目名称:freeorion,代码行数:10,代码来源:ServerNetworking.cpp

示例2: biggest_current_player_id

int ServerNetworking::NewPlayerID() const {
    int biggest_current_player_id(0);
    for (PlayerConnections::const_iterator it = m_player_connections.begin();
         it != m_player_connections.end(); ++it)
    {
        const PlayerConnectionPtr player = *it;
        int player_id = player->PlayerID();
        if (player_id != INVALID_PLAYER_ID && player_id > biggest_current_player_id)
            biggest_current_player_id = player_id;
    }
    return biggest_current_player_id + 1;
}
开发者ID:Ablu,项目名称:freeorion,代码行数:12,代码来源:ServerNetworking.cpp

示例3: GetPlayer

void ServerNetworking::Disconnect(int id) {
    established_iterator it = GetPlayer(id);
    if (it == established_end()) {
        Logger().errorStream() << "ServerNetworking::Disconnect couldn't find player with id " << id << " to disconnect.  aborting";
        return;
    }
    PlayerConnectionPtr player = *it;
    if (player->PlayerID() != id) {
        Logger().errorStream() << "ServerNetworking::Disconnect got PlayerConnectionPtr with inconsistent player id (" << player->PlayerID() << ") to what was requrested (" << id << ")";
        return;
    }
    Disconnect(player);
}
开发者ID:Ablu,项目名称:freeorion,代码行数:13,代码来源:ServerNetworking.cpp

示例4: DisconnectImpl

void ServerNetworking::DisconnectImpl(PlayerConnectionPtr player_connection) {
    if (TRACE_EXECUTION)
        Logger().debugStream() << "ServerNetworking::DisconnectImpl : disconnecting player "
                               << player_connection->PlayerID();
    m_player_connections.erase(player_connection);
    m_disconnected_callback(player_connection);
}
开发者ID:Ablu,项目名称:freeorion,代码行数:7,代码来源:ServerNetworking.cpp

示例5: SendMessage

void ServerNetworking::SendMessage(const Message& message,
                                   PlayerConnectionPtr player_connection)
{
    //if (TRACE_EXECUTION)
    //    Logger().debugStream() << "ServerNetworking::SendMessage : sending message "
    //                           << message;
    player_connection->SendMessage(message);
}
开发者ID:Ablu,项目名称:freeorion,代码行数:8,代码来源:ServerNetworking.cpp

示例6: AcceptConnection

void ServerNetworking::AcceptConnection(PlayerConnectionPtr player_connection,
                                        const boost::system::error_code& error)
{
    if (!error) {
        if (TRACE_EXECUTION)
            DebugLogger() << "ServerNetworking::AcceptConnection : connected to new player";
        m_player_connections.insert(player_connection);
        player_connection->Start();
        AcceptNextConnection();
    } else {
        throw error;
    }
}
开发者ID:Ouaz,项目名称:freeorion,代码行数:13,代码来源:ServerNetworking.cpp

示例7: established_end

void ServerNetworking::SendMessage(const Message& message) {
    if (message.ReceivingPlayer() == Networking::INVALID_PLAYER_ID) {
        // if recipient is INVALID_PLAYER_ID send message to all players
        for (ServerNetworking::const_established_iterator player_it = established_begin();
            player_it != established_end(); ++player_it)
        {
            (*player_it)->SendMessage(message);
        }
    } else {
        // send message to single player
        established_iterator it = GetPlayer(message.ReceivingPlayer());
        if (it == established_end()) {
            Logger().errorStream() << "ServerNetworking::SendMessage couldn't find player with id " << message.ReceivingPlayer() << " to disconnect.  aborting";
            return;
        }
        PlayerConnectionPtr player = *it;
        if (player->PlayerID() != message.ReceivingPlayer()) {
            Logger().errorStream() << "ServerNetworking::SendMessage got PlayerConnectionPtr with inconsistent player id (" << message.ReceivingPlayer() << ") to what was requrested (" << message.ReceivingPlayer() << ")";
            return;
        }
        player->SendMessage(message);
    }
}
开发者ID:Ablu,项目名称:freeorion,代码行数:23,代码来源:ServerNetworking.cpp

示例8:

////////////////////////////////////////////////////////////////////////////////
// ServerNetworking
////////////////////////////////////////////////////////////////////////////////
bool ServerNetworking::EstablishedPlayer::operator()(
    const PlayerConnectionPtr& player_connection) const
{ return player_connection->EstablishedPlayer(); }
开发者ID:Ablu,项目名称:freeorion,代码行数:6,代码来源:ServerNetworking.cpp


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