We do something similar with the remote debug protocol. <br><br>if you look at the file WEB-INF/lps/lfc/debugger/platform/swf/LzRemote.as you will see the usage<br>of the Flash APIs. They can be accessed as normal Javascript for the most part. <br>
<br>For example the code to open and send a message looks like <br><br>Debug.sockOpen = function (port) {<br> var url = LzBrowser.getLoadURLAsLzURL();<br> // Security requires us to talk back to the server we were loaded from<br>
var host = url.host;<br> this.xsock = new XMLSocket();<br> this.xsock.onClose = this.brokensocket;<br> this.xsock.onXML = this.socketXMLAvailable;<br> if (! this.xsock.connect(host, port)) {<br> Debug.log("remote debugger could not connect to listener " + host + ":" + port);<br>
}<br> this.writeInitMessage();<br>}<br><br><br>/**<br> * @access private<br> */<br>Debug.writeInitMessage = function () {<br> var filename = LzBrowser.getLoadURLAsLzURL();<br> var myXML = new XML();<br> var init = myXML.createElement("init"); <br>
myXML.appendChild(init);<br> init.attributes.filename = filename;<br> init.attributes.language = "LZX";<br> init.attributes.protocol_version = "1.0";<br> init.attributes.build = canvas.lpsbuild;<br>
init.attributes.lpsversion = canvas.lpsversion;<br> init.attributes.lpsrelease = canvas.lpsrelease;<br> init.attributes.runtime = canvas.runtime;<br> init.attributes.appid = "0";<br> this.xsock.send(myXML);<br>
}<br><br><br>and the code to hook into the callback for received XML looks like<br><br>Debug.socketXMLAvailable = function (doc) {<br> var e = doc.firstChild;<br> var rloader = Debug.rdbloader;<br> if (e != null) {<br>
// clear warnings history<br> Debug.resetWarningHistory();<br> Debug.inEvalRequest = true;<br> var seqnum = e.attributes['seq'];<br> if (seqnum == null) {<br> seqnum = Debug.seqnum++;<br>
}<br><br> if (e.nodeName == "exec") {<br> var expr = e.firstChild.nodeValue;<br> rloader.request( { lz_load : false,<br> lzt : "eval",<br>
proxied: true,<br> lzrdbseq : seqnum,<br> lz_script : "#file evalString\n#line 0\n" + expr } );<br> <br> } else if (e.nodeName == "eval") {<br>
var expr = e.firstChild.nodeValue;<br> rloader.request( { lz_load : false,<br> lzt : "eval",<br> proxied: true,<br> lzrdbseq : seqnum,<br>
lz_script : "#file evalString\n#line 0\n" + expr } );<br> } else if (e.nodeName == "inspect") {<br> Debug.inEvalRequest = false;<br> var id = <a href="http://e.attributes.id">e.attributes.id</a>;<br>
Debug.sockWriteAsXML(Debug.ObjectForID(id), seqnum);<br> } else {<br> Debug.inEvalRequest = false;<br> Debug.sockWrite("<response seq='"+seqnum+"'><error msg='unknown remote debug command'>"+e.nodeName+"</error></response>");<br>
}<br> } else {<br> Debug.inEvalRequest = false;<br> Debug.sockWrite("<response seq='-1'><error msg='null remote debug command'/></response>");<br> }<br>
}<br><br><br><br><br>You may want to put some of that code into a <script when="immediate"> block <br><br><div class="gmail_quote">On Thu, May 8, 2008 at 9:30 AM, Evaldas Taroza <<a href="mailto:etaroza@optaros.com">etaroza@optaros.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello,<br>
<br>
Thanks Henry for the pointer. Indeed I need a TCP socket. Normal Dataset will not do the job, I think.<br>
<br>
When you say to use Flash API, how do I do it? I mean, in Flash I suppose there is another programing language, like ActionScript, so how do I do it from within OL then?<br>
<br>
And when you say that Flash API is not officially supported by OL can it be that my app will eventually break, when you change somethings inside OL?<br>
<br>
A bit about my problems:<br>
As I told you I am taking my first steps with OL. So I decided to write some simple chat program, which would support a very small subset of XMPP. So as a start I need to send to the chat server the following text:<br>
<?xml version='1.0' encoding='UTF-8'?><br>
<stream:stream<br>
to='localhost'<br>
xmlns='jabber:client'<br>
xmlns:stream='<a href="http://etherx.jabber.org/streams" target="_blank">http://etherx.jabber.org/streams</a>'<br>
version='1.0'><br>
<br>
And the server responds to something similar as well. As you can see it is not a well-formed XML document, so I need to treat it as text and parse it. All the subsequent communication happens with well-formed XML snippets.<br>
<br>
Do you think it's possible?<br>
<br>
Evaldas<br>
<br>
Henry Minsky wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">
For streaming I/O to a TCP socket, if you restrict your self to the Flash runtime, you can use the Flash XMLSocket API , which has some restrictions, such as it must use TCP ports above 1024 I think.<br>
<br>
The API can be found in the Flash reference manual, it is not officially a supported API in OpelLaszlo though.<br>
<br>
We used this API for one of the remote debugger protocols at one point. There is still some code in the debugger implementation for it I think, which could be used as an example.<br>
<br>
<br></div><div class="Ih2E3d">
On Thu, May 8, 2008 at 12:35 AM, Evaldas Taroza <<a href="mailto:etaroza@optaros.com" target="_blank">etaroza@optaros.com</a> <mailto:<a href="mailto:etaroza@optaros.com" target="_blank">etaroza@optaros.com</a>>> wrote:<br>
<br>
Dear OL users,<br>
<br>
I am pretty new to OL. What I am trying to achieve is to open a<br>
socket to a host (crossdomain) and read incoming textual data.<br>
<br>
Incoming data will most likely be an XML document, but I don't want<br>
to read the whole document, I rather need to deal with it as it<br>
comes, in a streaming manner. How can I achieve this?<br>
<br>
Thank you very much for help!<br>
<br>
Evaldas<br>
<br>
-- +41 79 616 53 76<br></div>
<a href="http://www.linkedin.com/in/taroza" target="_blank">www.linkedin.com/in/taroza</a> <<a href="http://www.linkedin.com/in/taroza" target="_blank">http://www.linkedin.com/in/taroza</a>><br>
<br>
Optaros - <a href="http://www.optaros.com" target="_blank">www.optaros.com</a> <<a href="http://www.optaros.com" target="_blank">http://www.optaros.com</a>><br>
<br>
<br>
<br>
<br>
-- <br>
Henry Minsky<br>
Software Architect<br>
<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a> <mailto:<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a>><br>
<br>
</blockquote><div><div></div><div class="Wj3C7c">
<br>
<br>
<br>
-- <br>
+41 79 616 53 76<br>
<a href="http://www.linkedin.com/in/taroza" target="_blank">www.linkedin.com/in/taroza</a><br>
<br>
Optaros - <a href="http://www.optaros.com" target="_blank">www.optaros.com</a><br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Henry Minsky<br>Software Architect<br><a href="mailto:hminsky@laszlosystems.com">hminsky@laszlosystems.com</a><br><br>