Exemplo n.º 1
0
    protected void ProcessLayerData(LayerDataMessage message) // TODO: This should not be here
    {
        //Logger.LogDebug("Session.ProcessLayerData", "");

        // TODO: Verify that the sending endpoint is associated with the current region

        VolumeLayerData vlData = new VolumeLayerData
        {
            LayerType = message.LayerType,
            Data      = message.Data,
            Size      = message.Data.Length,
            Region    = Agent.CurrentPlayer?.Region
        };

        VolumeLayerManager.AddLayerData(vlData);
    }
Exemplo n.º 2
0
    public async Task Start(string uri, Credential credential, Slurl slurl = null, bool getInventoryLibrary = true, bool godMode = false)
    {
        List <Task> awaitables = new List <Task>();

        IsLoggedIn      = false;
        IsLogoutPending = false;

        #region Login
        Logger.LogDebug("Session.Start", "LOGIN------------------------------");
        EventManager.Instance.RaiseOnProgressUpdate("Login", "Logging in...", 0.2f);

        Login         login         = new Login();
        LoginResponse loginResponse = await login.Connect(uri, credential, slurl, getInventoryLibrary, godMode);

        if (loginResponse.LoginSucceeded == false)
        {
            EventManager.Instance.RaiseOnProgressUpdate("Login", "Login failed.", 0.29f, true);

            switch (loginResponse.LoginFailReason)
            {
            case "key":
                break;

            case "update":
                break;

            case "tos":
                break;
            }
            Logger.LogWarning("Session.Start", $"Login.Connect returned {loginResponse.MessageId} {loginResponse.Message}");
            return;
        }

        SessionId = loginResponse.SessionId;
        #endregion Login

        #region WorldInit
        Logger.LogDebug("Session.Start", "WORLD_INIT-------------------------");
        EventManager.Instance.RaiseOnProgressUpdate("Login", "Initializing world...", 0.3f);

        AgentId = loginResponse.AgentId;
        Agent agent = new Agent(loginResponse.AgentId)
        {
            DisplayName = loginResponse.DisplayName,
            FirstName   = loginResponse.FirstName,
            LastName    = loginResponse.LastName
        };
        Agent.SetCurrentPlayer(agent);
        EventManager.Instance.RaiseOnAgentDataChanged(agent);

        // Before we create the first region, we need to set the agent's OriginGlobal
        // This is necessary because creating objects before this is set will result in a
        // bad PositionAgent cache.
        agent.InitOriginGlobal(loginResponse.RegionHandle.ToVector3Double());

        FirstSimHost = new Host(loginResponse.SimIp, loginResponse.SimPort);
        Region region = World.Instance.AddRegion(loginResponse.RegionHandle, FirstSimHost);

        EventManager.Instance.RaiseOnProgressUpdate("Login", "Requesting capability grants...", 0.32f);

        Task seedCapabilitiesTask = region.SetSeedCapability(loginResponse.SeedCapability);

        agent.Region = region;
        #endregion WorldInit

        #region MultimediaInit
        Logger.LogDebug("Session.Start", "MULTIMEDIA_INIT--------------------");
        EventManager.Instance.RaiseOnProgressUpdate("Login", "Initializing multimedia...", 0.42f);

        #endregion MultimediaInit

        #region FontInit
        Logger.LogDebug("Session.Start", "FONT_INIT--------------------------");
        EventManager.Instance.RaiseOnProgressUpdate("Login", "Initializing fonts...", 0.45f);

        #endregion FontInit

        #region SeedGrantedWait
        Logger.LogDebug("Session.Start", "SEED_GRANTED_WAIT------------------");
        EventManager.Instance.RaiseOnProgressUpdate("Login", "Waiting for region capabilities...", 0.47f);

        await seedCapabilitiesTask;
        #endregion SeedGrantedWait

        #region SeedCapabilitiesGranted
        Logger.LogDebug("Session.Start", "SEED_CAPABILITIES_GRANTED----------");

        RegisterEventListeners();

        CircuitCode    = loginResponse.CircuitCode;
        region.Circuit = SlMessageSystem.Instance.EnableCircuit(new Host(loginResponse.SimIp, loginResponse.SimPort));

        EventManager.Instance.RaiseOnProgressUpdate("Login", "Waiting for region handshake...", 0.59f);
        await region.Circuit.SendUseCircuitCode(loginResponse.CircuitCode, SessionId, loginResponse.AgentId);

        AvatarNameCache.Instance.Start();
        #endregion SeedCapabilitiesGranted

        #region AgentSend
        Logger.LogDebug("Session.Start", "AGENT_SEND-------------------------");

        EventManager.Instance.RaiseOnProgressUpdate("Login", "Connecting to region...", 0.6f);
        await region.Circuit.SendCompleteAgentMovement(loginResponse.AgentId, SessionId, loginResponse.CircuitCode);

        #endregion AgentSend

        #region InventorySend
        Logger.LogDebug("Session.Start", "INVENTORY_SEND---------------------");

        //TODO: Fill in inventory skeleton and request details

        //Fill in buddy list skeleton and request names:
        AvatarTracker.Instance.AddBuddyList(loginResponse.BuddyList);

        // Set up callbacks:
        AvatarTracker.Instance.RegisterCallbacks();

        //TODO: Request mute list
        //TODO: Request money balance

        awaitables.Add(region.Circuit.SendAgentDataUpdateRequest(agent.Id, SessionId));

        #endregion InventorySend

        #region Misc
        Logger.LogDebug("Session.Start", "MISC-------------------------------");

        //TODO: Calculate max bandwidth
        awaitables.Add(region.Circuit.SendAgentThrottle());

        //TODO: Download audio
        //TODO: Download active gestures

        awaitables.Add(region.Circuit.SendAgentHeightWidth(1080, 1920)); // TODO: This should take the title and status bars into account.

        #endregion Misc

        #region Precache
        Logger.LogDebug("Session.Start", "PRECACHE---------------------------");
        EventManager.Instance.RaiseOnProgressUpdate("Login", "Loading world...", 0.9f);

        //TODO: Send AgentIsNowWearing

        await Task.WhenAll(awaitables.ToArray());

        awaitables.Clear();
        #endregion Precache

        #region Cleanup
        Logger.LogDebug("Session.Start", "CLEANUP----------------------------");

        //TODO: Make map view observe inventory
        //TODO: Make map view observe friends
        //TODO: Stop Away animation
        //TODO: Clear control flag Away

        // Observe friends
        Agent.CurrentPlayer.ObserveFriends();

        //TODO: Retrieve land description
        //TODO: Send hover height to capability "AgentPreferences"

        EventManager.Instance.RaiseOnProgressUpdate("Login", "Complete", 1f);
        await Task.Delay(1000); // Wait to let player see the "Complete" message.

        EventManager.Instance.RaiseOnProgressUpdate("Login", "", 1f, true);
        #endregion Cleanup

        IsLoggedIn = true;

        await Task.Delay(3000);

        Logger.LogDebug("Session.Start", "POST----------------");

        // TODO: This is in the application loop in Indra:
        VolumeLayerManager.UnpackLayerData();
    }