Exemple #1
0
        LoginResponseData HandleLogin(string firstName, string lastName, string password, string start, string version, string channel)
        {
            LoginResponseData response = new LoginResponseData();
            Agent             agent;

            UUID agentID = Authentication.Authenticate(firstName, lastName, password);

            if (agentID != UUID.Zero)
            {
                // Authentication successful, create a login instance of this agent
                agent = Accounts.CreateInstance(agentID);

                if (agent != null)
                {
                    // Assign a circuit code and insert the agent into the unassociatedAgents dictionary
                    agent.CircuitCode = UDP.CreateCircuit(agent);

                    agent.TickLastPacketReceived = Environment.TickCount;
                    agent.LastLoginTime          = Utils.DateTimeToUnixTime(DateTime.Now);

                    // Get this machine's IP address
                    IPHostEntry addresses = Dns.GetHostByName(Dns.GetHostName());
                    IPAddress   simIP     = addresses.AddressList.Length > 0 ? addresses.AddressList[0] : IPAddress.Loopback;

                    response.AgentID           = agent.AgentID;
                    response.SecureSessionID   = agent.SecureSessionID;
                    response.SessionID         = agent.SessionID;
                    response.CircuitCode       = agent.CircuitCode;
                    response.AgentAccess       = agent.AccessLevel;
                    response.BuddyList         = null; // FIXME:
                    response.FirstName         = agent.FirstName;
                    response.HomeLookAt        = agent.HomeLookAt;
                    response.HomePosition      = agent.HomePosition;
                    response.HomeRegion        = agent.HomeRegionHandle;
                    response.InventoryRoot     = agent.InventoryRoot;
                    response.InventorySkeleton = null; // FIXME:
                    response.LastName          = agent.LastName;
                    response.LibraryOwner      = agent.InventoryLibraryOwner;
                    response.LibraryRoot       = agent.InventoryLibraryRoot;
                    response.LibrarySkeleton   = null; // FIXME:
                    response.LookAt            = agent.CurrentLookAt;
                    response.Message           = "Welcome to Simian";
                    response.Reason            = String.Empty;

                    uint regionX, regionY;
                    Utils.LongToUInts(agent.CurrentRegionHandle, out regionX, out regionY);
                    response.RegionX = regionX;
                    response.RegionY = regionY;

                    response.SecondsSinceEpoch = DateTime.Now;
                    // FIXME: Actually generate a seed capability
                    response.SeedCapability = String.Format("http://{0}:{1}/seed_caps", simIP, HttpPort);
                    response.SimIP          = simIP;
                    response.SimPort        = (ushort)UDPPort;
                    response.StartLocation  = "last"; // FIXME:
                    response.Success        = true;
                }
                else
                {
                    // Something went wrong creating an agent instance, return a fail response
                    response.AgentID   = agentID;
                    response.FirstName = firstName;
                    response.LastName  = lastName;
                    response.Message   = "Failed to create an account instance";
                    response.Reason    = "account";
                    response.Success   = false;
                }
            }
            else
            {
                // Authentication failed, return a fail response
                response.AgentID   = agentID;
                response.FirstName = firstName;
                response.LastName  = lastName;
                response.Message   = "Authentication failed";
                response.Reason    = "key";
                response.Success   = false;
            }

            return(response);
        }