Ejemplo n.º 1
0
        public SecondLife.key SendRemoteData(SecondLife.key channel, string dest, int iData, string sData)
        {
            this.guid = new SecondLife.key(Guid.NewGuid());

            // Construct a request.
            string requestString = string.Format(@"<?xml version=""1.0""?>
 <methodCall>
     <methodName>llRemoteData</methodName>
     <params>
         <param>
             <value>
                 <struct>
                     <member>
                         <name>Channel</name>
                         <value><string>{0}</string></value>
                     </member>
                     <member>
                         <name>IntValue</name>
                         <value><int>{1}</int></value>
                     </member>
                     <member>
                         <name>StringValue</name>
                         <value><string>{2}</string></value>
                     </member>
                 </struct>
             </value>
         </param>
     </params>
 </methodCall>", channel.ToString(), iData, sData);

            request = WebRequest.Create(dest);

            byte[] buffer = System.Text.Encoding.UTF8.GetBytes(requestString);

            // Get a response stream and write the response to it.
            request.ContentLength = buffer.Length;
            request.ContentType   = "text/xml";
            System.IO.Stream requestStream = request.GetRequestStream();
            requestStream.Write(buffer, 0, buffer.Length);

            // You must close the request stream.
            requestStream.Close();

            thread      = new Thread(new ThreadStart(WaitOnResponse));
            thread.Name = "WaitOnResponse";
            thread.Start();

            return(this.guid);
        }
Ejemplo n.º 2
0
        public void RemoteDataReply(SecondLife.key channel, SecondLife.key message_id, string sData, int iData)
        {
            // Obtain a response object.
            HttpListenerResponse response = context.Response;

            // Construct a response.
            string responseString = string.Format(@"<?xml version=""1.0""?>
 <methodResponse>
     <params>
         <param>
             <value>
                 <struct>
                     <member>
                         <name>Channel</name>
                         <value><string>{0}</string></value>
                     </member>
                     <member>
                         <name>StringValue</name>
                         <value><string>{1}</string></value>
                     </member>
                     <member>
                         <name>IntValue</name>
                         <value><int>{2}</int></value>
                     </member>
                 </struct>
             </value>
         </param>
     </params>
 </methodResponse>", channel.ToString(), sData, iData);

            byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);

            // Get a response stream and write the response to it.
            response.ContentLength64 = buffer.Length;
            response.ContentType     = "text/xml";
            System.IO.Stream output = response.OutputStream;
            output.Write(buffer, 0, buffer.Length);

            // You must close the output stream.
            output.Close();
        }