Пример #1
0
void NetworkProxy::__internalNewConnectionEvent(const TcpConnectionPtr& connection, const NewConnectionEventArgs& args)
{
    debug_log("Enter NetworkProxy::__internalNewConnectionEvent --");

    //create game session
    GameSession* session = GameSessionManager::getInstance().createSession();
    session->init();
    session->set_connection_ptr(connection);
    connection->setUserData(session);

    debug_log(
        "New Session [NativeHandle = %d, SessionId = %ull, Peer = %s", 
        connection->handle(), 
        session->session_id(), 
        args.peer_address.toIpHost().c_str());

    auto callback = _dispatcher.sessionCreatedEvent;
    if (callback) 
    {
        callback(session);
    }
}