Example #1
0
 public Agent(SimulationObject avatar, AgentInfo info)
 {
     Avatar = avatar;
     Info = info;
 }
Example #2
0
        public bool EnableClientCapHandler(IHttpClientContext context, IHttpRequest request, IHttpResponse response, object state)
        {
            OSDMap map = OSDParser.DeserializeLLSDXml(request.Body) as OSDMap;
            OSDMap osdResponse = new OSDMap();

            if (map != null)
            {
                UUID agentID = map["agent_id"].AsUUID();
                UUID sessionID = map["session_id"].AsUUID();
                UUID secureSessionID = map["secure_session_id"].AsUUID();
                uint circuitCode = (uint)map["circuit_code"].AsInteger();
                // TODO: Send an identity url and token instead so we can pull down all of the information
                string firstName = map["first_name"].AsString();
                string lastName = map["last_name"].AsString();
                Uri callbackUri = map["callback_uri"].AsUri();

                Logger.Log(String.Format(
                    "enable_client request. agent_id: {0}, session_id: {1}, secureSessionID: {2}, " +
                    "first_name: {3}, last_name: {4}, callback_uri: {5}", agentID, sessionID, secureSessionID,
                    firstName, lastName, callbackUri), Helpers.LogLevel.Info);

                if (agentID != UUID.Zero && sessionID != UUID.Zero && secureSessionID != UUID.Zero &&
                    !String.IsNullOrEmpty(firstName) && !String.IsNullOrEmpty(lastName))
                {
                    AgentInfo info = new AgentInfo();
                    info.AccessLevel = "M";
                    info.FirstName = firstName;
                    info.Height = 1.9f;
                    info.HomeLookAt = Vector3.UnitZ;
                    info.HomePosition = new Vector3(128f, 128f, 25f);
                    info.HomeRegionHandle = regionHandle;
                    info.ID = agentID;
                    info.LastName = lastName;
                    info.PasswordHash = String.Empty;

                    Agent agent = new Agent(new SimulationObject(new Avatar(), this), info);

                    // Set the avatar ID
                    agent.Avatar.Prim.ID = agentID;

                    // Random session IDs
                    agent.SessionID = sessionID;
                    agent.SecureSessionID = secureSessionID;

                    // Create a seed capability for this agent
                    agent.SeedCapability = server.Capabilities.CreateCapability(SeedCapabilityHandler, false, agentID);

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

                    // Add the callback URI to the list of pending enable_client_complete callbacks
                    lock (enableClientCompleteCallbacks)
                        enableClientCompleteCallbacks[agentID] = callbackUri;

                    // Assign a circuit code and track the agent as an unassociated agent (no UDP connection yet)
                    udp.CreateCircuit(agent, circuitCode);
                    agent.CircuitCode = circuitCode;

                    osdResponse["success"] = OSD.FromBoolean(true);
                }
                else
                {
                    osdResponse["success"] = OSD.FromBoolean(false);
                    osdResponse["message"] = OSD.FromString("missing required fields for enable_client");
                }
            }
            else
            {
                osdResponse["success"] = OSD.FromBoolean(false);
                osdResponse["message"] = OSD.FromString("failed to parse enable_client message");
            }

            byte[] responseData = OSDParser.SerializeLLSDXmlBytes(osdResponse);
            response.ContentLength = responseData.Length;
            response.Body.Write(responseData, 0, responseData.Length);
            response.Body.Flush();

            return true;
        }