コード例 #1
0
 private void Chat(int channel, string name, SecondLife.key id, string message, CommunicationType how)
 {
     if (OnChat != null)
     {
         OnChat(this, new SecondLifeHostChatEventArgs(channel, name, id, message, how));
     }
 }
コード例 #2
0
        public llDialogForm(SecondLifeHost host, SecondLife.String strObjectName, SecondLife.key id, SecondLife.String strOwner, SecondLife.String strMessage, SecondLife.list buttons, SecondLife.integer intChannel)
        {
            InitializeComponent();

            this.host       = host;
            this.Channel    = intChannel;
            this.OwnerName  = strOwner;
            this.ObjectName = strObjectName;
            this.id         = id;

            for (int intI = 1; intI <= 12; intI++)
            {
                Button button = this.Controls["Button" + intI] as Button;
                button.Visible = false;
            }

            this.label1.Text = strOwner + "'s '" + strObjectName + "'";
            this.label2.Text = strMessage.ToString().Replace("&", "&&");

            for (int intI = 1; intI <= buttons.Count; intI++)
            {
                Button button = this.Controls["Button" + intI] as Button;
                if (button == null)
                {
                    continue;
                }
                button.Text    = buttons[intI - 1].ToString().Replace("&", "&&");
                button.Visible = true;
                button.Click  += new EventHandler(button_Click);
            }
        }
コード例 #3
0
        public llTextBoxForm(SecondLifeHost host, SecondLife.String strObjectName, SecondLife.key id, SecondLife.String strOwner, SecondLife.String strMessage, SecondLife.integer intChannel)
        {
            InitializeComponent();

            this.host       = host;
            this.Channel    = intChannel;
            this.OwnerName  = strOwner;
            this.ObjectName = strObjectName;
            this.id         = id;

            this.label1.Text = strMessage.ToString().Replace("&", "&&");
        }
コード例 #4
0
        public PermissionsForm(SecondLifeHost host, string strObjectName, SecondLife.key id, string strOwner, SecondLife.key agent, int intPermissions)
        {
            InitializeComponent();

            this.host           = host;
            this.OwnerName      = strOwner;
            this.ObjectName     = strObjectName;
            this.agent          = agent;
            this.id             = id;
            this.intPermissions = intPermissions;

            StringBuilder sb = new StringBuilder();

            if ((intPermissions & SecondLife.PERMISSION_DEBIT) == SecondLife.PERMISSION_DEBIT)
            {
                sb.AppendLine("Take Linden dollars (L$) from you");
            }

            if ((intPermissions & SecondLife.PERMISSION_TAKE_CONTROLS) == SecondLife.PERMISSION_TAKE_CONTROLS)
            {
                sb.AppendLine("Act on your control inputs");
            }

            if ((intPermissions & SecondLife.PERMISSION_TRIGGER_ANIMATION) == SecondLife.PERMISSION_TRIGGER_ANIMATION)
            {
                sb.AppendLine("Animate your avatar");
            }

            if ((intPermissions & SecondLife.PERMISSION_ATTACH) == SecondLife.PERMISSION_ATTACH)
            {
                sb.AppendLine("Attach to your avatar");
            }

            if ((intPermissions & SecondLife.PERMISSION_CHANGE_LINKS) == SecondLife.PERMISSION_CHANGE_LINKS)
            {
                sb.AppendLine("Link and delink from other objects");
            }

            if ((intPermissions & SecondLife.PERMISSION_TRACK_CAMERA) == SecondLife.PERMISSION_TRACK_CAMERA)
            {
                sb.AppendLine("Track your camera");
            }

            if ((intPermissions & SecondLife.PERMISSION_CONTROL_CAMERA) == SecondLife.PERMISSION_CONTROL_CAMERA)
            {
                sb.AppendLine("Control your camera");
            }

            this.label1.Text = "'" + strObjectName + "', an object owned by '" + strOwner + "',\nwould like to:";
            this.label2.Text = sb.ToString();
        }
コード例 #5
0
        private void Speak(CommunicationType how)
        {
            int    intChannel = 0;
            string strMessage = this.textBox1.Text.Trim();

            History.Add(strMessage);
            intHistory = History.Count;


            if (strMessage != "")
            {
                if (strMessage[0] == '/')
                {
                    if (strMessage.StartsWith("/me"))
                    {
                        // do nothing
                    }
                    else
                    {
                        string strChannel = "";
                        for (int intI = 1; intI < strMessage.Length; intI++)
                        {
                            if (strMessage[intI] >= '0' && strMessage[intI] <= '9')
                            {
                                strChannel += strMessage[intI];
                                if (intI < 10)
                                {
                                    continue;
                                }
                            }
                            try {
                                intChannel = Convert.ToInt32(strChannel);
                                strMessage = strMessage.Substring(intI).Trim();
                            } catch {
                            }
                            break;
                        }
                    }
                }
            }

            SecondLife.key id = new SecondLife.key(Properties.Settings.Default.AvatarKey);

            Chat(intChannel, Properties.Settings.Default.AvatarName, id, strMessage, how);

            this.textBox1.Clear();

            this.buttonSay.Enabled   = false;
            this.buttonShout.Enabled = false;
        }
コード例 #6
0
        private object[] GetArguments(string strName, string strArgs)
        {
            object[] objResult = new object[0];
            if (strArgs != "")
            {
                try {
                    string[] args       = strArgs.Trim().Split(new char[] { ',' });
                    object[] argobjects = new object[args.Length];
                    for (int intI = 0; intI < argobjects.Length; intI++)
                    {
                        string[] argument = args[intI].Trim().Split(new char[] { ' ' });
                        if (argument.Length == 2)
                        {
                            string[] arArgs;
                            string   strArgumentValue = GetArgumentValue(strName + "_" + intI);
                            string   strArgumentName  = argument[1];
                            string   strArgumentType  = argument[0];
                            switch (strArgumentType)
                            {
                            case "System.String":
                                argobjects[intI] = strArgumentValue;
                                break;

                            case "System.Int32":
                                argobjects[intI] = int.Parse(strArgumentValue);
                                break;

                            case "LSLEditor.SecondLife+Float":
                                argobjects[intI] = new SecondLife.Float(strArgumentValue);
                                break;

                            case "LSLEditor.SecondLife+integer":
                                argobjects[intI] = new SecondLife.integer(int.Parse(strArgumentValue));
                                break;

                            case "LSLEditor.SecondLife+String":
                                argobjects[intI] = new SecondLife.String(strArgumentValue);
                                break;

                            case "LSLEditor.SecondLife+key":
                                argobjects[intI] = new SecondLife.key(strArgumentValue);
                                break;

                            case "LSLEditor.SecondLife+list":
                                argobjects[intI] = new SecondLife.list(new string[] { strArgumentValue });
                                break;

                            case "LSLEditor.SecondLife+rotation":
                                arArgs           = strArgumentValue.Replace("<", "").Replace(">", "").Replace(" ", "").Split(new char[] { ',' });
                                argobjects[intI] = new SecondLife.rotation(double.Parse(arArgs[0]), double.Parse(arArgs[1]), double.Parse(arArgs[2]), double.Parse(arArgs[3]));
                                break;

                            case "LSLEditor.SecondLife+vector":
                                arArgs           = strArgumentValue.Replace("<", "").Replace(">", "").Replace(" ", "").Split(new char[] { ',' });
                                argobjects[intI] = new SecondLife.vector(double.Parse(arArgs[0]), double.Parse(arArgs[1]), double.Parse(arArgs[2]));
                                break;

                            default:
                                MessageBox.Show("Compiler->GetArguments->[" + strArgumentType + "][" + strArgumentName + "]");
                                argobjects[intI] = null;
                                break;
                            }
                        }
                        else
                        {
                            MessageBox.Show("Argument must be 'type name' [" + args[intI] + "]");
                            break;
                        }
                    }
                    objResult = argobjects;
                } catch { }
            }
            return(objResult);
        }
コード例 #7
0
		public WebRequestClass(WebProxy proxy, SecondLife secondlife, string strUrl, SecondLife.list parameters, string postData, SecondLife.key key)
		{
			try
			{
				// Create a new webrequest to the mentioned URL.   
				WebRequest myWebRequest = WebRequest.Create(strUrl);

				myWebRequest.Headers.Add("Cache-Control", "max-age=259200");
				//myWebRequest.Headers.Add("Connection", "keep-alive");
				myWebRequest.Headers.Add("Pragma", "no-cache");
				//myWebRequest.Headers.Add("Via", "1.1 sim3560.agni.lindenlab.com:3128 (squid/2.6.STABLE12)");
				//myWebRequest.Headers.Add("Content-Length", "3");
				//myWebRequest.Headers.Add("Content-Type", "text/plain;charset=utf-8");
				//myWebRequest.Headers.Add("Accept", "text/*");
				myWebRequest.Headers.Add("Accept-Charset", "utf-8;q=1.0, *;q=0.5");
				myWebRequest.Headers.Add("Accept-Encoding", "deflate, gzip");
				//myWebRequest.Headers.Add("Host", "www.lsleditor.org");
				//myWebRequest.Headers.Add("User-Agent", "LSLEditor 2.24 (http://www.lsleditor.org)");
				myWebRequest.Headers.Add("X-SecondLife-Shard", "Production");

				SecondLife.vector RegionCorner = secondlife.llGetRegionCorner();
				SecondLife.vector pos = secondlife.llGetPos();

				myWebRequest.Headers.Add("X-SecondLife-Object-Name", secondlife.host.GetObjectName());
				myWebRequest.Headers.Add("X-SecondLife-Object-Key", secondlife.host.GetKey().ToString());
				myWebRequest.Headers.Add("X-SecondLife-Region", Properties.Settings.Default.RegionName + " (" + (int)RegionCorner.x + ", " + (int)RegionCorner.y + ")");
				myWebRequest.Headers.Add("X-SecondLife-Local-Position", "("+pos.x+", "+pos.y+", "+pos.z+")");
				myWebRequest.Headers.Add("X-SecondLife-Local-Rotation", "(0.000000, 0.000000, 0.000000, 1.000000)");
				myWebRequest.Headers.Add("X-SecondLife-Local-Velocity", "(0.000000, 0.000000, 0.000000)");
				myWebRequest.Headers.Add("X-SecondLife-Owner-Name", Properties.Settings.Default.AvatarName);
				myWebRequest.Headers.Add("X-SecondLife-Owner-Key", Properties.Settings.Default.AvatarKey);
				myWebRequest.Headers.Add("X-Forwarded-For", "127.0.0.1");

				// Setting up paramters
				for (int intI = 0; intI < parameters.Count; intI += 2)
				{
					switch (int.Parse(parameters[intI].ToString()))
					{
						case 0:
							myWebRequest.Method = parameters[intI + 1].ToString();
							break;
						case 1:
							myWebRequest.ContentType = parameters[intI + 1].ToString();
							break;
						case 2:
							// HTTP_BODY_MAXLENGTH
							break;
						default:
							break;
					}
				}

				if (proxy != null)
					myWebRequest.Proxy = proxy;

				// Create a new instance of the RequestState.
				RequestState myRequestState = new RequestState();

				myRequestState.secondlife = secondlife;
				myRequestState.httpkey = key;
				myRequestState.postData = Encoding.UTF8.GetBytes(postData);

				// 19 sep 2007
				myWebRequest.ContentLength = myRequestState.postData.Length;

				// The 'WebRequest' object is associated to the 'RequestState' object.
				myRequestState.request = myWebRequest;

				// Start the Asynchronous call for response.
				IAsyncResult asyncResult;
				if (myWebRequest.Method == "POST" || myWebRequest.Method == "PUT")
					asyncResult = (IAsyncResult)myWebRequest.BeginGetRequestStream(new AsyncCallback(RespCallback), myRequestState);
				else
					asyncResult = (IAsyncResult)myWebRequest.BeginGetResponse(new AsyncCallback(RespCallback), myRequestState);
			}
			catch (WebException e)
			{
				secondlife.host.VerboseMessage(e.Message);
				secondlife.host.VerboseMessage(e.Status.ToString());
			}
			catch (Exception e)
			{
				Console.WriteLine("Exception raised!");
				Console.WriteLine("Source : " + e.Source);
				Console.WriteLine("Message : " + e.Message);
				secondlife.host.VerboseMessage(e.Message);
			}
		}
コード例 #8
0
        public static void Request(WebProxy proxy, SecondLife secondlife, string strUrl, SecondLife.list parameters, string postData, SecondLife.key key)
        {
            string strMethod      = "GET";
            string strContentType = "text/plain; charset=utf-8";

            for (int intI = 0; intI < parameters.Count; intI += 2)
            {
                int intKey;
                if (!int.TryParse(parameters[intI].ToString(), out intKey))
                {
                    continue;
                }
                switch (intKey)
                {
                case 0:
                    // get, post, put, delete
                    strMethod = parameters[intI + 1].ToString().ToUpper();
                    break;

                case 1:
                    strContentType = parameters[intI + 1].ToString();
                    break;

                case 2:
                    // HTTP_BODY_MAXLENGTH
                    break;

                case 3:
                    // HTTP_VERIFY_CERT
                    break;

                default:
                    break;
                }
            }

            WebClient wc = new WebClient();

            wc.Headers.Add("Content-Type", strContentType);
            wc.Headers.Add("Accept", "text/*");
            wc.Headers.Add("Accept-Charset", "utf-8; q=1.0, *; q=0.5");
            wc.Headers.Add("Accept-Encoding", "deflate, gzip");
            wc.Headers.Add("User-Agent", "Second Life LSL/1.19.0(12345) (http://secondlife.com)");

            System.Drawing.Point point        = Properties.Settings.Default.RegionCorner;
            SecondLife.vector    RegionCorner = new SecondLife.vector(point.X, point.Y, 0);

            SecondLife.vector pos = secondlife.GetLocalPos;

            wc.Headers.Add("X-SecondLife-Shard", Properties.Settings.Default.XSecondLifeShard);
            wc.Headers.Add("X-SecondLife-Object-Name", secondlife.host.GetObjectName());
            wc.Headers.Add("X-SecondLife-Object-Key", secondlife.host.GetKey().ToString());
            wc.Headers.Add("X-SecondLife-Region", string.Format("{0} ({1}, {2})", Properties.Settings.Default.RegionName, (int)RegionCorner.x, (int)RegionCorner.y));
            wc.Headers.Add("X-SecondLife-Local-Position", string.Format("({0}, {1}, {2})", pos.x, pos.y, pos.z));
            wc.Headers.Add("X-SecondLife-Local-Rotation", "(0.000000, 0.000000, 0.000000, 1.000000)");
            wc.Headers.Add("X-SecondLife-Local-Velocity", "(0.000000, 0.000000, 0.000000)");
            wc.Headers.Add("X-SecondLife-Owner-Name", Properties.Settings.Default.AvatarName);
            wc.Headers.Add("X-SecondLife-Owner-Key", Properties.Settings.Default.AvatarKey);
            wc.Headers.Add("X-Forwarded-For", "127.0.0.1");

            if (proxy != null)
            {
                wc.Proxy = proxy;
            }

            Uri uri = new Uri(strUrl);

            // Basic Authentication scheme, added 28 mrt 2008
            if (uri.UserInfo != "")
            {
                string[] UserInfo = uri.UserInfo.Split(':');
                if (UserInfo.Length == 2)
                {
                    CredentialCache mycache = new CredentialCache();
                    mycache.Add(uri, "Basic",
                                new NetworkCredential(UserInfo[0], UserInfo[1]));
                    wc.Credentials = mycache;
                }
            }


            UserState userState = new UserState(key, secondlife);

            if (strMethod == "POST" || strMethod == "PUT")
            {
                wc.UploadDataCompleted += new UploadDataCompletedEventHandler(wc_UploadDataCompleted);
                wc.UploadDataAsync(uri, strMethod, Encoding.UTF8.GetBytes(postData), userState);
            }
            else
            {
                wc.DownloadDataCompleted += new DownloadDataCompletedEventHandler(wc_DownloadDataCompleted);
                wc.DownloadDataAsync(uri, userState);
            }
        }
コード例 #9
0
 public UserState(SecondLife.key httpkey, SecondLife secondlife)
 {
     this.secondlife = secondlife;
     this.httpkey    = httpkey;
 }