Here's my problem: I have a NetConnection object connected to a server. On top I create a NetStream object and it started to play a file from the server. Classic so far.
What I need now, is to be able to send some (short) messages back to the server, at various moments during playtime but, clearly, using the existing TCP connection.
From what I can read in the docs, the underlying NetConnection object supports "two-way connection between a client and a server" and obviously the TCP layer supports it. I am aware of TCP networking concepts fairly well, but definitely not of how Flash implements them.
Is this correct? Can it be done using NetConnection (or some other mechanism)?
How would I go about doing this (an example would be great, but a conceptual description of the process would work just as well). How exactly do I send a message from the client to the server via NetConnection?
Does the active NetStream object interfere in any way with such an operation?
Thanks.
Yes, you can.
I assume, we are talking about connection to Flash media Server.
Use NetConnection.call() method which remotely executes server-side script method.
You have to define this server-side method as a prototype of connection client class
e.g.
Then calling this method should look like:
If you need to get some result - use Responder class instance instead of null.
If you need server to call client's method use server-side "call" function on client object. In this case you'll have to define some object at client side, wich has the callback method:
Client side:
Server side:
Regards, David.