Take a look at the Adobe documentation on XMLSocket, it may be possible to just send<br>null terminated strings instead of well formed XML. I recall something like that is possible. <br><br><br><br><br><div class="gmail_quote">
On Thu, May 8, 2008 at 10:02 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;">
Thanks for the code, it gave me initial idea on where to start. Still, the code is showing XMLSocket, so it assumes that I am receiving XML data. But As I mentioned previously, the incoming data (at least in the beginning) is not well formed XML and should be treated as a simple string...<br>
<br>
So I suppose there is some Flash API for that, isn't there?<br>
<br>
How does it work technically that OL can communicate to Flash using Javascript?<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><div></div><div class="Wj3C7c">
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>
} else if (e.nodeName == "eval") {<br>
var expr = e.firstChild.nodeValue;<br>
rloader.request( { lz_load : false,<br>
lzt : "eval",<br>
proxied: true,<br></div></div>
&n bsp; lzrdbseq : seqnum,<div class="Ih2E3d"><br>
lz_script : "#file evalString\n#line 0\n" + expr } );<br>
} else if (e.nodeName == "inspect") {<br>
Debug.inEvalRequest = false;<br></div>
var id = <a href="http://e.attributes.id" target="_blank">e.attributes.id</a> <<a href="http://e.attributes.id" target="_blank">http://e.attributes.id</a>>;<div class="Ih2E3d"><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><div><div></div><div class="Wj3C7c">
On Thu, May 8, 2008 at 9:30 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>
Hello,<br>
<br>
Thanks Henry for the pointer. Indeed I need a TCP socket. Normal<br>
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<br>
suppose there is another programing language, like ActionScript, so<br>
how do I do it from within OL then?<br>
<br>
And when you say that Flash API is not officially supported by OL<br>
can it be that my app will eventually break, when you change<br>
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<br>
write some simple chat program, which would support a very small<br>
subset of XMPP. So as a start I need to send to the chat server the<br>
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<br>
it is not a well-formed XML document, so I need to treat it as text<br>
and parse it. All the subsequent communication happens with<br>
well-formed XML snippets.<br>
<br>
Do you think it's possible?<br>
<br>
Evaldas<br>
<br>
Henry Minsky wrote:<br>
<br>
For streaming I/O to a TCP socket, if you restrict your self to<br>
the Flash runtime, you can use the Flash XMLSocket API , which<br>
has some restrictions, such as it must use TCP ports above 1024<br>
I think.<br>
<br>
The API can be found in the Flash reference manual, it is not<br>
officially a supported API in OpelLaszlo though.<br>
<br>
We used this API for one of the remote debugger protocols at one<br>
point. There is still some code in the debugger implementation<br>
for it I think, which could be used as an example.<br>
<br>
<br>
On Thu, May 8, 2008 at 12:35 AM, Evaldas Taroza<br>
<<a href="mailto:etaroza@optaros.com" target="_blank">etaroza@optaros.com</a><br>
<mailto:<a href="mailto:etaroza@optaros.com" target="_blank">etaroza@optaros.com</a>><br></div></div>
<mailto:<a href="mailto:etaroza@optaros.com" target="_blank">etaroza@optaros.com</a><div class="Ih2E3d"><br>
<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<br>
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>
<a href="http://www.linkedin.com/in/taroza" target="_blank">www.linkedin.com/in/taroza</a><br>
<<a href="http://www.linkedin.com/in/taroza" target="_blank">http://www.linkedin.com/in/taroza</a>><br>
<<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>
<<a href="http://www.optaros.com" target="_blank">http://www.optaros.com</a>><br>
<br>
<br>
<br>
<br>
-- Henry Minsky<br>
Software Architect<br>
<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a><br>
<mailto:<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a>><br></div>
<mailto:<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a><div class="Ih2E3d"><br>
<mailto:<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a>>><br>
<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> <<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>
</div></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>