StartRequest() public method

public StartRequest ( ) : void
return void
Esempio n. 1
0
       /// <summary>
       /// Start a friends confrence
       /// </summary>
       /// <param name="participants"><seealso cref="UUID"/> List of UUIDs to start a confrence with</param>
       /// <param name="tmp_session_id"><seealso cref="UUID"/>a Unique UUID that will be returned in the OnJoinedGroupChat callback></param>
       public void StartIMConfrence(List <UUID> participants,UUID tmp_session_id)
       {
           if (Client.Network.CurrentSim == null || Client.Network.CurrentSim.Caps == null)
               throw new Exception("ChatSessionRequest capability is not currently available");

            Uri url = Client.Network.CurrentSim.Caps.CapabilityURI("ChatSessionRequest");

            if (url != null)
            {
                OSDMap req = new OSDMap();
                req.Add("method", OSD.FromString("start conference"));
                OSDArray members = new OSDArray();
                foreach(UUID participant in participants)
                    members.Add(OSD.FromUUID(participant));

                req.Add("params",members);
                req.Add("session-id", OSD.FromUUID(tmp_session_id));

                byte[] postData = StructuredData.OSDParser.SerializeLLSDXmlBytes(req);

                Console.WriteLine(req.ToString());

                CapsClient request = new CapsClient(url);
                request.StartRequest(postData);
            }
            else
            {
                throw new Exception("ChatSessionRequest capability is not currently available");
            }
        }
Esempio n. 2
0
        private bool RequestVoiceInternal(string me, CapsClient.CompleteCallback callback, string capsName)
        {
            if (Enabled && Client.Network.Connected)
            {
                if (Client.Network.CurrentSim != null && Client.Network.CurrentSim.Caps != null)
                {
                    Uri url = Client.Network.CurrentSim.Caps.CapabilityURI(capsName);

                    if (url != null)
                    {
                        CapsClient request = new CapsClient(url);
                        OSDMap body = new OSDMap();
                        request.OnComplete += new CapsClient.CompleteCallback(callback);
                        request.StartRequest(body);

                        return true;
                    }
                    else
                    {
                        Logger.Log("VoiceManager." + me + "(): " + capsName + " capability is missing", 
                                   Helpers.LogLevel.Info, Client);
                        return false;
                    }
                }
            }

            Logger.Log("VoiceManager.RequestVoiceInternal(): Voice system is currently disabled", 
                       Helpers.LogLevel.Info, Client);
            return false;
            
        }
Esempio n. 3
0
        /// <summary>
        /// Accept invite for to a chatterbox session
        /// </summary>
        /// <param name="session_id"><seealso cref="UUID"/> of session to accept invite to</param>
        public void ChatterBoxAcceptInvite(UUID session_id)
        {
            if (Client.Network.CurrentSim == null || Client.Network.CurrentSim.Caps == null)
                throw new Exception("ChatSessionRequest capability is not currently available");

            Uri url = Client.Network.CurrentSim.Caps.CapabilityURI("ChatSessionRequest");

            if (url != null)
            {
                OSDMap req = new OSDMap();
                req.Add("method", OSD.FromString("accept invitation"));
                req.Add("session-id", OSD.FromUUID(session_id));

                byte[] postData = StructuredData.OSDParser.SerializeLLSDXmlBytes(req);

                CapsClient request = new CapsClient(url);
                request.StartRequest(postData);
            }
            else
            {
                throw new Exception("ChatSessionRequest capability is not currently available");
            }

       }
Esempio n. 4
0
        /// <summary>
        /// Returns the new user ID or throws an exception containing the error code
        /// The error codes can be found here: https://wiki.secondlife.com/wiki/RegAPIError
        /// </summary>
        /// <param name="user">New user account to create</param>
        /// <returns>The UUID of the new user account</returns>
        public UUID CreateUser(CreateUserParam user)
        {
            if (Initializing)
                throw new InvalidOperationException("still initializing");

            if (_caps.CreateUser == null)
                throw new InvalidOperationException("access denied; only approved developers have access to the registration api");

            // Create the POST data
            OSDMap query = new OSDMap();
            query.Add("username", OSD.FromString(user.FirstName));
            query.Add("last_name_id", OSD.FromInteger(user.LastName.ID));
            query.Add("email", OSD.FromString(user.Email));
            query.Add("password", OSD.FromString(user.Password));
            query.Add("dob", OSD.FromString(user.Birthdate.ToString("yyyy-MM-dd")));

            if (user.LimitedToEstate != null)
                query.Add("limited_to_estate", OSD.FromInteger(user.LimitedToEstate.Value));

            if (!string.IsNullOrEmpty(user.StartRegionName))
                query.Add("start_region_name", OSD.FromInteger(user.LimitedToEstate.Value));

            if (user.StartLocation != null)
            {
                query.Add("start_local_x", OSD.FromReal(user.StartLocation.Value.X));
                query.Add("start_local_y", OSD.FromReal(user.StartLocation.Value.Y));
                query.Add("start_local_z", OSD.FromReal(user.StartLocation.Value.Z));
            }

            if (user.StartLookAt != null)
            {
                query.Add("start_look_at_x", OSD.FromReal(user.StartLookAt.Value.X));
                query.Add("start_look_at_y", OSD.FromReal(user.StartLookAt.Value.Y));
                query.Add("start_look_at_z", OSD.FromReal(user.StartLookAt.Value.Z));
            }

            //byte[] postData = OSDParser.SerializeXmlBytes(query);

            // Make the request
            CapsClient request = new CapsClient(_caps.CreateUser);
            request.OnComplete += new CapsClient.CompleteCallback(CreateUserResponse);
            request.StartRequest();

            // FIXME: Block
            return UUID.Zero;
        }
Esempio n. 5
0
        /// <summary>
        /// Update the simulator with any local changes to this Parcel object
        /// </summary>
        /// <param name="simulator">Simulator to send updates to</param>
        /// <param name="wantReply">Whether we want the simulator to confirm
        /// the update with a reply packet or not</param>
        public void Update(Simulator simulator, bool wantReply)
        {
            Uri url = simulator.Caps.CapabilityURI("ParcelPropertiesUpdate");

            if (url != null)
            {
                OSDMap body = new OSDMap();
                body["auth_buyer_id"] =  OSD.FromUUID(this.AuthBuyerID);
                body["auto_scale"] =  OSD.FromInteger(this.Media.MediaAutoScale);
                body["category"] = OSD.FromInteger((byte)this.Category);
                body["description"] = OSD.FromString(this.Desc);
                body["flags"] =  OSD.FromBinary(Utils.EmptyBytes);
                body["group_id"] = OSD.FromUUID(this.GroupID);
                body["landing_type"] = OSD.FromInteger((byte)this.Landing);
                body["local_id"] = OSD.FromInteger(this.LocalID);
                body["media_desc"] = OSD.FromString(this.Media.MediaDesc);
                body["media_height"] = OSD.FromInteger(this.Media.MediaHeight);
                body["media_id"] = OSD.FromUUID(this.Media.MediaID);
                body["media_loop"] = OSD.FromInteger(this.Media.MediaLoop ? 1 : 0);
                body["media_type"] = OSD.FromString(this.Media.MediaType);
                body["media_url"] = OSD.FromString(this.Media.MediaURL);
                body["media_width"] = OSD.FromInteger(this.Media.MediaWidth);
                body["music_url"] = OSD.FromString(this.MusicURL);
                body["name"] = OSD.FromString(this.Name);
                body["obscure_media"]= OSD.FromInteger(this.ObscureMedia ? 1 : 0);
                body["obscure_music"] = OSD.FromInteger(this.ObscureMusic ? 1 : 0);

                byte[] flags = Utils.IntToBytes((int)this.Flags); ;
                if (BitConverter.IsLittleEndian)
                    Array.Reverse(flags);
                body["parcel_flags"] = OSD.FromBinary(flags);

                body["pass_hours"] = OSD.FromReal(this.PassHours);
                body["pass_price"] = OSD.FromInteger(this.PassPrice);
                body["sale_price"] = OSD.FromInteger(this.SalePrice);
                body["snapshot_id"] = OSD.FromUUID(this.SnapshotID);
                OSDArray uloc = new OSDArray();
                uloc.Add(OSD.FromReal(this.UserLocation.X));
                uloc.Add(OSD.FromReal(this.UserLocation.Y));
                uloc.Add(OSD.FromReal(this.UserLocation.Z));
                body["user_location"] = uloc;
                OSDArray ulat = new OSDArray();
                ulat.Add(OSD.FromReal(this.UserLocation.X));
                ulat.Add(OSD.FromReal(this.UserLocation.Y));
                ulat.Add(OSD.FromReal(this.UserLocation.Z));
                body["user_look_at"] = ulat;

                //Console.WriteLine("OSD REQUEST\n{0}", body.ToString());

                byte[] postData = StructuredData.OSDParser.SerializeLLSDXmlBytes(body);
                //Console.WriteLine("{0}", OSDParser.SerializeLLSDXmlString(body));
                CapsClient capsPost = new CapsClient(url);
                capsPost.StartRequest(postData);

            }
            else
            {

                ParcelPropertiesUpdatePacket request = new ParcelPropertiesUpdatePacket();

                request.AgentData.AgentID = simulator.Client.Self.AgentID;
                request.AgentData.SessionID = simulator.Client.Self.SessionID;

                request.ParcelData.LocalID = this.LocalID;

                request.ParcelData.AuthBuyerID = this.AuthBuyerID;
                request.ParcelData.Category = (byte)this.Category;
                request.ParcelData.Desc = Utils.StringToBytes(this.Desc);
                request.ParcelData.GroupID = this.GroupID;
                request.ParcelData.LandingType = (byte)this.Landing;
                request.ParcelData.MediaAutoScale = this.Media.MediaAutoScale;
                request.ParcelData.MediaID = this.Media.MediaID;
                request.ParcelData.MediaURL = Utils.StringToBytes(this.Media.MediaURL);
                request.ParcelData.MusicURL = Utils.StringToBytes(this.MusicURL);
                request.ParcelData.Name = Utils.StringToBytes(this.Name);
                if (wantReply) request.ParcelData.Flags = 1;
                request.ParcelData.ParcelFlags = (uint)this.Flags;
                request.ParcelData.PassHours = this.PassHours;
                request.ParcelData.PassPrice = this.PassPrice;
                request.ParcelData.SalePrice = this.SalePrice;
                request.ParcelData.SnapshotID = this.SnapshotID;
                request.ParcelData.UserLocation = this.UserLocation;
                request.ParcelData.UserLookAt = this.UserLookAt;

                simulator.SendPacket(request, true);
            }

            UpdateOtherCleanTime(simulator);
            
        }
Esempio n. 6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="layer"></param>
        public void RequestMapLayer(GridLayerType layer)
        {
            Uri url = Client.Network.CurrentSim.Caps.CapabilityURI("MapLayer");

            if (url != null)
            {
                OSDMap body = new OSDMap();
                body["Flags"] = OSD.FromInteger((int)layer);

                CapsClient request = new CapsClient(url);
                request.OnComplete += new CapsClient.CompleteCallback(MapLayerResponseHandler);
                request.StartRequest(body);
            }
        }
Esempio n. 7
0
        public void InformClientOfNeighbors(Agent agent)
        {
            for (int i = 0; i < 8; i++)
            {
                if (!agent.NeighborConnections[i] && neighbors[i].Online)
                {
                    Logger.Log("Sending enable_client for " + agent.FullName + " to neighbor " + neighbors[i].Name, Helpers.LogLevel.Info);

                    // Create a callback for enable_client_complete
                    Uri callbackUri = server.Capabilities.CreateCapability(EnableClientCompleteCapHandler, false, null);

                    OSDMap enableClient = CapsMessages.EnableClient(agent.ID, agent.SessionID, agent.SecureSessionID,
                        (int)agent.CircuitCode, agent.Info.FirstName, agent.Info.LastName, callbackUri);

                    AutoResetEvent waitEvent = new AutoResetEvent(false);

                    CapsClient request = new CapsClient(neighbors[i].EnableClientCap);
                    request.OnComplete +=
                    delegate(CapsClient client, OSD result, Exception error)
                    {
                        OSDMap response = result as OSDMap;
                        if (response != null)
                        {
                            bool success = response["success"].AsBoolean();
                            Logger.Log("enable_client response: " + success, Helpers.LogLevel.Info);

                            if (success)
                            {
                                // Send the EnableSimulator capability to clients
                                RegionInfo neighbor = neighbors[i];
                                OSDMap enableSimulator = CapsMessages.EnableSimulator(neighbor.Handle, neighbor.IPAndPort.Address, neighbor.IPAndPort.Port);

                                SendEvent(agent, "EnableSimulator", enableSimulator);
                            }
                        }
                        waitEvent.Set();
                    };
                    request.StartRequest(enableClient);

                    if (!waitEvent.WaitOne(30 * 1000, false))
                        Logger.Log("enable_client request timed out", Helpers.LogLevel.Warning);
                }
            }
        }
Esempio n. 8
0
        private void GatherCaps()
        {
            // build post data
            byte[] postData = Encoding.ASCII.GetBytes(
                String.Format("first_name={0}&last_name={1}&password={2}", _userInfo.FirstName, _userInfo.LastName, 
                _userInfo.Password));

            CapsClient request = new CapsClient(RegistrationApiCaps);
            request.OnComplete += new CapsClient.CompleteCallback(GatherCapsResponse);
            request.StartRequest(postData);
        }
Esempio n. 9
0
        private void GatherErrorMessages()
        {
            if (_caps.GetErrorCodes == null)
                throw new InvalidOperationException("access denied");	// this should work even for not-approved users

            CapsClient request = new CapsClient(_caps.GetErrorCodes);
            request.OnComplete += new CapsClient.CompleteCallback(GatherErrorMessagesResponse);
            request.StartRequest();
        }
Esempio n. 10
0
        private void UploadNotecardAssetResponse(CapsClient client, OSD result, Exception error)
        {
            OSDMap contents = (OSDMap)result;
            KeyValuePair<NotecardUploadedAssetCallback, byte[]> kvp = (KeyValuePair<NotecardUploadedAssetCallback, byte[]>)(((object[])client.UserData)[0]);
            NotecardUploadedAssetCallback callback = kvp.Key;
            byte[] itemData = (byte[])kvp.Value;

            string status = contents["state"].AsString();

            if (status == "upload")
            {
                string uploadURL = contents["uploader"].AsString();

                // This makes the assumption that all uploads go to CurrentSim, to avoid
                // the problem of HttpRequestState not knowing anything about simulators
                CapsClient upload = new CapsClient(new Uri(uploadURL));
                upload.OnComplete += new CapsClient.CompleteCallback(UploadNotecardAssetResponse);
                upload.UserData = new object[2] { kvp, (UUID)(((object[])client.UserData)[1]) };
                upload.StartRequest(itemData, "application/octet-stream");
            }
            else if (status == "complete")
            {
                if (contents.ContainsKey("new_asset"))
                {
                    try { callback(true, String.Empty, (UUID)(((object[])client.UserData)[1]), contents["new_asset"].AsUUID()); }
                    catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, _Client, e); }
                }
                else
                {
                    try { callback(false, "Failed to parse asset and item UUIDs", UUID.Zero, UUID.Zero); }
                    catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, _Client, e); }
                }
            }
            else
            {
                // Failure
                try { callback(false, status, UUID.Zero, UUID.Zero); }
                catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, _Client, e); }
            }
        }
Esempio n. 11
0
        private void BeginLogin()
        {
            LoginParams loginParams = CurrentContext.Value;

            // Sanity check
            if (loginParams.Options == null)
                loginParams.Options = new List<string>();

            // Convert the password to MD5 if it isn't already
            if (loginParams.Password.Length != 35 && !loginParams.Password.StartsWith("$1$"))
                loginParams.Password = Utils.MD5(loginParams.Password);

            // Override SSL authentication mechanisms. DO NOT convert this to the
            // .NET 2.0 preferred method, the equivalent function in Mono has a
            // different name and it will break compatibility!
            #pragma warning disable 0618
            ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy();
            // TODO: At some point, maybe we should check the cert?

            // Create the CAPS login structure
            OSDMap loginLLSD = new OSDMap();
            loginLLSD["first"] = OSD.FromString(loginParams.FirstName);
            loginLLSD["last"] = OSD.FromString(loginParams.LastName);
            loginLLSD["passwd"] = OSD.FromString(loginParams.Password);
            loginLLSD["start"] = OSD.FromString(loginParams.Start);
            loginLLSD["channel"] = OSD.FromString(loginParams.Channel);
            loginLLSD["version"] = OSD.FromString(loginParams.Version);
            loginLLSD["platform"] = OSD.FromString(loginParams.Platform);
            loginLLSD["mac"] = OSD.FromString(loginParams.MAC);
            loginLLSD["agree_to_tos"] = OSD.FromBoolean(true);
            loginLLSD["read_critical"] = OSD.FromBoolean(true);
            loginLLSD["viewer_digest"] = OSD.FromString(loginParams.ViewerDigest);
            loginLLSD["id0"] = OSD.FromString(loginParams.id0);

            // Create the options LLSD array
            OSDArray optionsOSD = new OSDArray();
            for (int i = 0; i < loginParams.Options.Count; i++)
                optionsOSD.Add(OSD.FromString(loginParams.Options[i]));
            foreach (string[] callbackOpts in CallbackOptions.Values)
            {
                if (callbackOpts != null)
                {
                    for (int i = 0; i < callbackOpts.Length; i++)
                    {
                        if (!optionsOSD.Contains(callbackOpts[i]))
                            optionsOSD.Add(callbackOpts[i]);
                    }
                }
            }
            loginLLSD["options"] = optionsOSD;

            // Make the CAPS POST for login
            Uri loginUri;
            try
            {
                loginUri = new Uri(loginParams.URI);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Failed to parse login URI {0}, {1}", loginParams.URI, ex.Message),
                    Helpers.LogLevel.Error, Client);
                throw ex;
            }

            CapsClient loginRequest = new CapsClient(loginUri);
            loginRequest.OnComplete += new CapsClient.CompleteCallback(LoginReplyHandler);
            loginRequest.UserData = CurrentContext;
            UpdateLoginStatus(LoginStatus.ConnectingToLogin, String.Format("Logging in as {0} {1}...", loginParams.FirstName, loginParams.LastName));
            loginRequest.StartRequest(OSDParser.SerializeLLSDXmlBytes(loginLLSD), "application/xml+llsd");
        }
Esempio n. 12
0
        private void CreateItemFromAssetResponse(CapsClient client, OSD result, Exception error)
        {
            object[] args = (object[])client.UserData;
            CapsClient.ProgressCallback progCallback = (CapsClient.ProgressCallback)args[0];
            ItemCreatedFromAssetCallback callback = (ItemCreatedFromAssetCallback)args[1];
            byte[] itemData = (byte[])args[2];

            if (result == null)
            {
                try { callback(false, error.Message, UUID.Zero, UUID.Zero); }
                catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, _Client, e); }
                return;
            }

            OSDMap contents = (OSDMap)result;

            string status = contents["state"].AsString().ToLower();

            if (status == "upload")
            {
                string uploadURL = contents["uploader"].AsString();

                Logger.DebugLog("CreateItemFromAsset: uploading to " + uploadURL);

                // This makes the assumption that all uploads go to CurrentSim, to avoid
                // the problem of HttpRequestState not knowing anything about simulators
                CapsClient upload = new CapsClient(new Uri(uploadURL));
                upload.OnProgress += progCallback;
                upload.OnComplete += new CapsClient.CompleteCallback(CreateItemFromAssetResponse);
                upload.UserData = new object[] { null, callback, itemData };
                upload.StartRequest(itemData, "application/octet-stream");
            }
            else if (status == "complete")
            {
                Logger.DebugLog("CreateItemFromAsset: completed");

                if (contents.ContainsKey("new_inventory_item") && contents.ContainsKey("new_asset"))
                {
                    try { callback(true, String.Empty, contents["new_inventory_item"].AsUUID(), contents["new_asset"].AsUUID()); }
                    catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, _Client, e); }
                }
                else
                {
                    try { callback(false, "Failed to parse asset and item UUIDs", UUID.Zero, UUID.Zero); }
                    catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, _Client, e); }
                }
            }
            else
            {
                // Failure
                try { callback(false, status, UUID.Zero, UUID.Zero); }
                catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, _Client, e); }
            }
        }
Esempio n. 13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <param name="notecardID"></param>
        /// <param name="callback"></param>
        public void RequestUploadNotecardAsset(byte[] data, UUID notecardID, NotecardUploadedAssetCallback callback)
        {
            if (_Client.Network.CurrentSim == null || _Client.Network.CurrentSim.Caps == null)
                throw new Exception("UpdateNotecardAgentInventory capability is not currently available");

            Uri url = _Client.Network.CurrentSim.Caps.CapabilityURI("UpdateNotecardAgentInventory");

            if (url != null)
            {
                OSDMap query = new OSDMap();
                query.Add("item_id", OSD.FromUUID(notecardID));

                byte[] postData = StructuredData.OSDParser.SerializeLLSDXmlBytes(query);

                // Make the request
                CapsClient request = new CapsClient(url);
                request.OnComplete += new CapsClient.CompleteCallback(UploadNotecardAssetResponse);
                request.UserData = new object[2] { new KeyValuePair<NotecardUploadedAssetCallback, byte[]>(callback, data), notecardID };
                request.StartRequest(postData);
            }
            else
            {
                throw new Exception("UpdateNotecardAgentInventory capability is not currently available");
            }
        }
Esempio n. 14
0
        public void RequestCreateItemFromAsset(byte[] data, string name, string description, AssetType assetType,
            InventoryType invType, UUID folderID, CapsClient.ProgressCallback progCallback, ItemCreatedFromAssetCallback callback)
        {
            if (_Client.Network.CurrentSim == null || _Client.Network.CurrentSim.Caps == null)
                throw new Exception("NewFileAgentInventory capability is not currently available");

            Uri url = _Client.Network.CurrentSim.Caps.CapabilityURI("NewFileAgentInventory");

            if (url != null)
            {
                OSDMap query = new OSDMap();
                query.Add("folder_id", OSD.FromUUID(folderID));
                query.Add("asset_type", OSD.FromString(AssetTypeToString(assetType)));
                query.Add("inventory_type", OSD.FromString(InventoryTypeToString(invType)));
                query.Add("name", OSD.FromString(name));
                query.Add("description", OSD.FromString(description));

                // Make the request
                CapsClient request = new CapsClient(url);
                request.OnComplete += new CapsClient.CompleteCallback(CreateItemFromAssetResponse);
                request.UserData = new object[] { progCallback, callback, data };

                request.StartRequest(query);
            }
            else
            {
                throw new Exception("NewFileAgentInventory capability is not currently available");
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Moderate a chat session
        /// </summary>
        /// <param name="sessionID">the <see cref="UUID"/> of the session to moderate, for group chats this will be the groups UUID</param>
        /// <param name="memberID">the <see cref="UUID"/> of the avatar to moderate</param>
        /// <param name="moderateText">true to moderate (silence user), false to allow avatar to speak</param>
        public void ModerateChatSessions(UUID sessionID, UUID memberID, bool moderateText)
        {
            if (Client.Network.CurrentSim == null || Client.Network.CurrentSim.Caps == null)
                throw new Exception("ChatSessionRequest capability is not currently available");

            Uri url = Client.Network.CurrentSim.Caps.CapabilityURI("ChatSessionRequest");

            if (url != null)
            {
                OSDMap req = new OSDMap();
                req.Add("method", OSD.FromString("mute update"));

                OSDMap mute_info = new OSDMap();
                mute_info.Add("text", OSD.FromBoolean(moderateText));

                OSDMap parameters = new OSDMap();
                parameters["agent_id"] = OSD.FromUUID(memberID);
                parameters["mute_info"] = mute_info;

                req["params"] = parameters;

                req.Add("session-id", OSD.FromUUID(sessionID));

                byte[] postData = StructuredData.OSDParser.SerializeLLSDXmlBytes(req);

                CapsClient request = new CapsClient(url);
                request.StartRequest(postData);
            }
            else
            {
                throw new Exception("ChatSessionRequest capability is not currently available");
            }
        }
Esempio n. 16
0
        public void GatherLastNames()
        {
            if (Initializing)
                throw new InvalidOperationException("still initializing");

            if (_caps.GetLastNames == null)
                throw new InvalidOperationException("access denied: only approved developers have access to the registration api");

            CapsClient request = new CapsClient(_caps.GetLastNames);
            request.OnComplete += new CapsClient.CompleteCallback(GatherLastNamesResponse);
            request.StartRequest();

            // FIXME: Block
        }
Esempio n. 17
0
        private void ProxyLoginSD(NetworkStream netStream, byte[] content)
        {
            lock (this) {
                ServicePointManager.CertificatePolicy = new OpenMetaverse.AcceptAllCertificatePolicy();
                AutoResetEvent remoteComplete = new AutoResetEvent(false);
                //CapsClient loginRequest = new CapsClient(proxyConfig.remoteLoginUri);
                CapsClient loginRequest = new CapsClient(new Uri("https://login1.aditi.lindenlab.com/cgi-bin/auth.cgi"));
                OSD response = null;
                loginRequest.OnComplete += new CapsClient.CompleteCallback(
                    delegate(CapsClient client, OSD result, Exception error)
                    {
                        if (error == null) {
                            if (result != null && result.Type == OSDType.Map) {
                                response = result;
                            }
                        }
                        remoteComplete.Set();
                    }
                    );
                loginRequest.StartRequest(content, "application/xml"); //xml+llsd
                remoteComplete.WaitOne(30000, false);

                if (response == null) {
                    byte[] wr = Encoding.ASCII.GetBytes("HTTP/1.0 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n");
                    netStream.Write(wr, 0, wr.Length);
                    return;
                }

                OSDMap map = (OSDMap)response;

                OSD llsd;
                string sim_port = null, sim_ip = null, seed_capability = null;
                map.TryGetValue("sim_port", out llsd);
                if (llsd != null) sim_port = llsd.AsString();
                map.TryGetValue("sim_ip", out llsd);
                if (llsd != null) sim_ip = llsd.AsString();
                map.TryGetValue("seed_capability", out llsd);
                if (llsd != null) seed_capability = llsd.AsString();

                if (sim_port == null || sim_ip == null || seed_capability == null) {
                    byte[] wr = Encoding.ASCII.GetBytes("HTTP/1.0 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n");
                    netStream.Write(wr, 0, wr.Length);
                    return;
                }

                IPEndPoint realSim = new IPEndPoint(IPAddress.Parse(sim_ip), Convert.ToUInt16(sim_port));
                IPEndPoint fakeSim = ProxySim(realSim);
                map["sim_ip"] = OSD.FromString(fakeSim.Address.ToString());
                map["sim_port"] = OSD.FromInteger(fakeSim.Port);
                activeCircuit = realSim;

                // start a new proxy session
                Reset();

                CapInfo info = new CapInfo(seed_capability, activeCircuit, "SeedCapability");
                info.AddDelegate(new CapsDelegate(FixupSeedCapsResponse));

                KnownCaps[seed_capability] = info;
                map["seed_capability"] = OSD.FromString(loginURI + seed_capability);

                StreamWriter writer = new StreamWriter(netStream);
                writer.Write("HTTP/1.0 200 OK\r\n");
                writer.Write("Content-type: application/xml+llsd\r\n");
                writer.Write("\r\n");
                writer.Write(OSDParser.SerializeLLSDXmlString(response));
                writer.Close();
            }
        }
Esempio n. 18
0
        public bool CheckName(string firstName, LastName lastName)
        {
            if (Initializing)
                throw new InvalidOperationException("still initializing");

            if (_caps.CheckName == null)
                throw new InvalidOperationException("access denied; only approved developers have access to the registration api");

            // Create the POST data
            OSDMap query = new OSDMap();
            query.Add("username", OSD.FromString(firstName));
            query.Add("last_name_id", OSD.FromInteger(lastName.ID));
            //byte[] postData = OSDParser.SerializeXmlBytes(query);

            CapsClient request = new CapsClient(_caps.CheckName);
            request.OnComplete += new CapsClient.CompleteCallback(CheckNameResponse);
            request.StartRequest();

            // FIXME:
            return false;
        }
Esempio n. 19
0
        private void MakeSeedRequest()
        {
            if (Simulator == null || !Simulator.Client.Network.Connected)
                return;

            // Create a request list
            OSDArray req = new OSDArray();
            req.Add("ChatSessionRequest");
            req.Add("CopyInventoryFromNotecard");
            req.Add("DispatchRegionInfo");
            req.Add("EstateChangeInfo");
            req.Add("EventQueueGet");
            req.Add("FetchInventoryDescendents");
            req.Add("GroupProposalBallot");
            req.Add("MapLayer");
            req.Add("MapLayerGod");
            req.Add("NewFileAgentInventory");
            req.Add("ParcelPropertiesUpdate");
            req.Add("ParcelVoiceInfoRequest");
            req.Add("ProvisionVoiceAccountRequest");
            req.Add("RemoteParcelRequest");
            req.Add("RequestTextureDownload");
            req.Add("SearchStatRequest");
            req.Add("SearchStatTracking");
            req.Add("SendPostcard");
            req.Add("SendUserReport");
            req.Add("SendUserReportWithScreenshot");
            req.Add("ServerReleaseNotes");
            req.Add("StartGroupProposal");
            req.Add("UpdateGestureAgentInventory");
            req.Add("UpdateNotecardAgentInventory");
            req.Add("UpdateScriptAgent");
            req.Add("UpdateGestureTaskInventory");
            req.Add("UpdateNotecardTaskInventory");
            req.Add("UpdateScriptTask");
            req.Add("ViewerStartAuction");
            req.Add("UntrustedSimulatorMessage");
            req.Add("ViewerStats");

            _SeedRequest = new CapsClient(new Uri(_SeedCapsURI));
            _SeedRequest.OnComplete += new CapsClient.CompleteCallback(SeedRequestCompleteHandler);
            _SeedRequest.StartRequest(req);
        }
Esempio n. 20
0
        void udp_OnAgentConnection(Agent agent, uint circuitCode)
        {
            Uri callbackUri;
            if (enableClientCompleteCallbacks.TryGetValue(agent.ID, out callbackUri))
            {
                lock (enableClientCompleteCallbacks)
                    enableClientCompleteCallbacks.Remove(agent.ID);

                Logger.Log("Sending enable_client_complete callback to " + callbackUri.ToString(), Helpers.LogLevel.Info);

                OSDMap enableClientComplete = CapsMessages.EnableClientComplete(agent.ID);

                AutoResetEvent waitEvent = new AutoResetEvent(false);

                CapsClient request = new CapsClient(callbackUri);
                request.OnComplete +=
                    delegate(CapsClient client, OSD result, Exception error)
                    {
                        OSDMap response = result as OSDMap;
                        if (response != null)
                        {
                            bool success = response["success"].AsBoolean();
                            Logger.Log("enable_client_complete response: " + success, Helpers.LogLevel.Info);

                            if (success)
                            {
                                Uri seedCapability = response["seed_capability"].AsUri();
                            }
                        }
                        waitEvent.Set();
                    };
                request.StartRequest(enableClientComplete);

                if (!waitEvent.WaitOne(30 * 1000, false))
                    Logger.Log("enable_client_complete request timed out", Helpers.LogLevel.Warning);
            }
        }