Results 1 to 6 of 6

Thread: Call a function for all stream viewers

  1. #1
    Join Date
    Feb 2011
    Posts
    18

    Default Call a function for all stream viewers

    Hello! How can I call function for all clients who watched specific stream?
    We have a button "show ad" for streamers. When streamer press the button server should run call("showAd") for all clients who watch this stream.
    What is the best way to implement this functionality?

  2. #2
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    Take a look at the ServerSideModules example in examples folder where Wowza is installed. A Flash client is included. It is a working reference of Flash/Wowza communications.

    Richard

  3. #3
    Join Date
    Feb 2011
    Posts
    18

    Default

    Quote Originally Posted by rrlanham View Post
    Take a look at the ServerSideModules example in examples folder where Wowza is installed. A Flash client is included. It is a working reference of Flash/Wowza communications.

    Richard
    I know how to call a single client =) I've already written 4 modules
    The question is how to call all clients simultaneously or get an array of clients who watch the specified stream.

    Something like (would be ideal):
    stream.broadcastMsg("someClientSideCallback");
    or (worse, but also rules)

    Iterator<IClient> iter = stream.getClients().iterator();
    while(iter.hasNext())
    {
    	IClient client = iter.next();
            client.call("someClientSideCallback");
    }
    Is there a similar function in Stream object, or I'll have to save all clients connecting to an array by myself?

  4. #4
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    You can use NetStream.send("someClientCallBack")

    Then you have to setup callback on the NetStream object instead of the NetConnection object, which is done exactly the same way.

    Richard
    Last edited by rrlanham; 12-15-2011 at 11:39 AM.

  5. #5
    Join Date
    Feb 2011
    Posts
    18

    Default

    It looks like my English is quite far from ideal =)
    I need to call function on client side!

    The full procedure is as follows:

    1) Clients connect to the server and begin to watch stream
    2) The streamer clicks the "show advertising." Called netConnection.call("showAd", null, "myStreamName");
    3) The server runs the function:
    	public void showAd(IClient client, RequestFunction function, AMFDataList params)
    	{
    		String streamName = params.getString(PARAM1);
                    IMediaStream stream = client.getAppInstance().getStreams().getStream(streamName);
                    
                    //Here i should call "showAds" for all clients who watch the stream myStreamName.
            }
    As a result, each client who is currently looking stream should call showAds.

  6. #6
    Join Date
    Feb 2011
    Posts
    18

    Default

    I solved the problem

    	
    public void showAd(IClient client, RequestFunction function, AMFDataList params)
    {
    	String streamName = params.getString(PARAM1);
            IMediaStream stream = client.getAppInstance().getStreams().getStream(streamName);
                    
            stream.send("showAd");   
    }
    on server

    and

    NetStream.client = this
    in player

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •