Jani Pirkola kirjoitti:
> There is an example of two-way http communication, it is used in the 
> x10 example:
> http://wiki.realxtend.org/index.php/How_to_Connect_Home_Automation_-_X10

interestingly enough that seems to use both some .net http lib (the one 
included with opensim? or from .net libs?) and urllib, i guess 
httpserver for listening to commands from outside, and python stdlib 
urllib for sending own commands

http://forge.opensimulator.org/gf/project/modrex/scmsvn/?action=browse&path=%2Ftrunk%2FModularRex%2FRexParts%2FRexPython%2FResources%2FPythonScript%2FRXCore%2FrxX10.py&revision=52&view=markup&pathrev=79
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import urllib

#listening, i think
X10Connection.httpServerThread = X10StateListenerThread()

#sending
url = 'http://' + X10Connection.X10ManagerAddress + 
'/X10/command?address=' + device + '&function=' + command
try:
    sock = urllib.urlopen(url)
    reponseBody = sock.read()

perhaps a bit strange to use different libs for the different directions 
in the same module, but at least it shows that both ways work :p

> Jani

~Toni

> 2009/4/9 Toni Alatalo <[email protected] <mailto:[email protected]>>
>
>
>     yuzo wrote:
>     > From my limited understanding, the Iron Python scripts for REX
>     live on
>     > the server. The LSL scripts seem to me something you construct in an
>     > editor on the viewer.
>     >
>
>     both are on the server, and executed on the server.
>
>     in opensim using the same scriptengine i think, am actually not 100%
>     sure of the details there now.
>
>     true, there is the difference that rexscripts you edit on the server,
>     whereas lsl you can edit via the viewer. but that just a UI and a
>     storage difference in the end, does not make a difference with
>     regard to
>     the execution, which is essentially similarily within an opensim
>     plugin
>     (and iirc using the same scriptengine).
>
>     a major difference is that the rexscript ones can pretty much do
>     anything, are like opensim region modules too in that sense, can
>     access
>     the system etc. like in any .net code i think. that's because it's
>     full
>     ironpython also, which can do anything c# can. so only for region
>     owners
>     in that sense i guess. Adam has been now working on the mini region
>     module (MRM) system for Opensim and looking into sandboxing execution
>     contexts with the .net tools (the one he was thinking of is not
>     supported in Mono).
>
>     afaik the lsl ones are converted to c# source and compiled, haven't
>     looked at that part of scriptengine now. security i guess comes just
>     from the fact that, err, only valid lsl is parsed and it can't do
>     stuff
>     like import .net modules? dunno.
>
>     > Does it make a difference if a script written in LSL by my avatar's
>     > viewer gets information from a data source and uses it, or if I do
>     > something similar as an Iron Python script? It just feels like the
>     > Iron Python script would be accessible globally and I would assume
>     > that scripts are local to the avatar associated with its
>     creation. Of
>     > course my understanding may be completely off.
>     >
>
>     there is no association from a rexscript module or class to avatars or
>     any other objects.
>
>     basically any object can use any such script, i.e. be declared to
>     be an
>     instance of that class. of course just the object owner can change the
>     property that which script is used for the object.
>
>     > Yuzo
>     >
>
>     ~Toni
>
>     > On Apr 8, 12:58 pm, Toni Alatalo <[email protected]
>     <mailto:[email protected]>> wrote:
>     >
>     >> Jeroen van Veen wrote:
>     >>
>     >>> if other python libs can be imported, maybe it can be done
>     with pycurl?
>     >>>
>     >> basics are also in the
>     stdlib,http://docs.python.org/library/urllib.html
>     >>
>     >> filehandle = urllib.urlopen(some_url, proxies=proxies)
>     >>
>     >> i guess the way to use curl within .net (which the server, being
>     >> opensim, is) would be via some .net wrapper, dunno, if you
>     needed that
>     >> for some reason.
>     >>
>     >> and like said in the other post, it may be also a good idea to
>     do what
>     >> opensim does on the c# side, what you would do in an opensim region
>     >> module perhaps (of course rexscript can also expose it by wrapping
>     >> something itself, or using what is exposed for LSL (which are what
>     >> rexscript usually uses)).
>     >>
>     >>
>     >>> Jeroen
>     >>>
>     >> ~Toni
>     >>
>     >>
>     >>> On Wednesday 08 April 2009 18:55:13 Jani Pirkola wrote:
>     >>>
>     >>>> Toni,
>     >>>> isn't it possible to send http get requests from python
>     directly? Or at
>     >>>> least open tcp socket and write the get request there? What
>     do I need to do
>     >>>> to enable needed libraries, ie does python in rex work as it
>     was any python
>     >>>> environment?
>     >>>>
>     >>>> Jani
>     >>>>
>     >>>> 2009/4/8 Toni Alatalo <[email protected]
>     <mailto:[email protected]>>
>     >>>>
>     >>>>> zeshu wrote:
>     >>>>>
>     >>>>>> I have some data on a php web page.Now i need that data in
>     realXtend.i
>     >>>>>> checked two methods in LSL one is httprequest and
>     XML-RPC.How i can
>     >>>>>> use these functions in Python.
>     >>>>>>
>     >>>>> are they exposed in the rexscript system? basically it
>     always calls the
>     >>>>> opensim scripting api,
>     >>>>> i.e. is same as the lsl impls.
>     >>>>>
>     >>>>> i think you can also use any .net library that your system
>     has installed
>     >>>>> on your server,
>     >>>>> similarily to how use in it c# but just within ironpython (which
>     >>>>> rexscript uses).
>     >>>>>
>     >>>>> ~Toni
>     >>>>>
>     >
>     > >
>
>
>
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/realxtend
http://www.realxtend.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to