Skip to main content
Inspiring
April 4, 2008
Question

Unclear documentation

  • April 4, 2008
  • 4 replies
  • 452 views
I'm trying to use a server-side script to call a function on the client side, but do not understand the documentation. I have created a function (Test) on the client, but do not understand what I am supposed to put into the ss script. The documentation states that I should use:

application.streams["foo"].send("Test", "hello world");

What am I supposed to put in place of streams["foo"]?
    This topic has been closed for replies.

    4 replies

    April 13, 2008
    FMS comes with sevaral samples you can play with.

    You can also search the internet.
    ie .adobe.com samples. http://www.adobe.com/devnet/flashmediaserver/sample_apps.html

    Good luck.

    Carlos
    SiHoopAuthor
    Inspiring
    April 10, 2008
    OK I understand what you mean. I agree that it would help to start with a working sample-- do you know of any such cases that exist online?
    SiHoopAuthor
    Inspiring
    April 4, 2008
    Carlos,
    Thanks for answering my question. Everything you say makes sense, but I still have a problem.

    Here's my server side code:
    application.onConnect=function(newClient, streamName){
    this.acceptConnection(newClient);
    application.streams[streamName].send("Test", "hello world");
    }

    I get the following error message:
    TypeError: application.streams has no properties

    If I trace streamName I get:
    streamName=undefined

    I suspect the problem is in my connection code: Should I create the NetStream before the NetConnection onStatus event handler?

    flashcom = "rtmp:/simon";
    var myConnection = new NetConnection();
    movieToPlay = "day1_floor";
    myConnection.onStatus = function(infoCode) {
    myNetStream = new NetStream(this);
    myNetStream.play(movieToPlay,0);
    videoWin.attachVideo(myNetStream);
    };
    myConnection.connect(flashcom);
    April 9, 2008
    You are getting the error because streams object is not created yet or the stream you are refering to does not have a send method. The method send needs to exist before calling it. If the specific stream object does not have a send method, you will need to define it either in the client or server sides.

    Also, the application.onConnect method has two parameters (in this case): client and streamName. You aren't passing the streamName on the client when calling connect.

    It would be easier for you starting with working sample to study the code and how the objects relate to each other.
    You can add trace functions to follow the sequence of tasks.

    Hope this helps.
    April 4, 2008
    Application represents the server application, you need to get a reference for the client object in order to call any of its methods.
    In your line of code streams is the lists of all streams being served. streams["foo"] means you will refer to the stream object named "foo" that exists in the list. You will need to know the stream name in order to do anything.

    Something helpfull to understand is to get a reference for the client object and the stream as follows:

    // You call the connect method on the client side with following parameters. When it connects the onConnect event will rise.

    application.onConnect = function(p_client, streamName)
    {
    this.acceptConnection(p_client);
    // then you can do anything with the streams or client objects.
    // ie.
    application.streams[streamName].send("Test", "hello world");
    // or you can have a showMessage method on the client and call it
    p_client.showMessage("send this message");
    // etc.
    }

    //Hope this helps.

    Carlos