Issues Calling Client Methods from Server (FMS 3.5)
Hi all,
I'm a bit puzzled here. I've looked online for a bunch of examples/samples, but, none of them seem to work or give me a straight answer. Here's my setup/situation:
- Flash Media Server 3.5 (using ActionScript 3 for server-side code)
- Flex application (built in Flex Builder 3, using ActionScript 3)
Now, I'm trying to get the server-side ASC code to call something from a connected client. It doesn't seem to work (thought everything else works beautifully). I've tried stuff like the following in the server side:
- In the application.onConnect function, I've tried this:
...
currentClient.requestChat = function (reqID, destID)
{
trace("Requesting chat...");
currentClient.call("requestWaiting", new reqHandler(), reqID, destID);
};
...
(Where reqHandler is just some handler that I know gets called).
- I've also tried the following code outside the onConnect function:
Client.prototype.requestChat = function (reqID, destID)
{
trace("Requesting chat...");
this.call("requestWaiting", new reqHandler(), reqID, destID);
}
Both seem to fire appropriately (when triggered from another client). However, the "requestWaiting" method call to the clients doesn't seem to work at all. I've tried some AS 2 examples on the client side, like:
nc = new NetConnection();
nc.client = new Object();
// function for handling queueing of requests for this station
nc.client.requestWaiting = function (reqID:String, destID:String):void {
trace("HELLO");
// check to make sure this is the right location, and if so, queue it
if (destID == "WhateverTheIDIs") {
chatQueue.push(reqID);
btnChatWaiting.visible = true;
} // if
}
...but that doesn't seem to fire at all. I know the Flex has "sealed" the NetConnection class itself, so I can't just "extend" it as I do the "client" property.
I've als tried some more AS 3-oriented stuff, like trying to make the "client" property reference a separate class that handles callbacks, but that doesn't work easily for me as I need access to properties in the class that contains the NetConnection.
Any help/tips would be GREATLY appreciated. I'm still fairly new to Flash/Flex, but I'm loving Flash Media Server.
Thanks in advance!
Cheers,
Duncan
