hi there, ive been trying to work out how to notify a currently subscribed client if a live broadcast is available or not when they connect. I have a method to invoke currently connected clients that a show has started with this code, when publishing in record mode i had to make a patch to some code to be able to get the published name as referenced on trac.

public void streamPublishStart(IBroadcastStream stream) {
        // Notify all the clients that the stream had been started
        //log.info(this.archivePath);
        isLive = true;
        streamName = stream.getPublishedName();
       
        log.info("stream broadcast start: "+stream.getPublishedName());
       
        ISharedObject so = getSharedObject(scope, "broadcaster");
        so.setAttribute("isLive", true);
       
        IConnection current = Red5.getConnectionLocal();
       
        Iterator<IConnection> it = scope.getConnections();
        while (it.hasNext()) {
            IConnection conn = it.next();
           
            if (conn.equals(current))
                // Don't notify current client
                continue;
           
           
            if (conn instanceof IServiceCapableConnection) {
                ((IServiceCapableConnection) conn).invoke("onBroadcast", new Object[]{stream.getPublishedName()}, this);
                log.info("sending notification to "+conn);
            }
        }
       
    }


now im also needing to notify the client just connecting so they dont get a trailer playlist and connect instead

public void streamSubscriberStart(ISubscriberStream stream) {
        IConnection conn = Red5.getConnectionLocal();

        Object[] streams = getStreams().toArray();
        String streamName = streams[0].toString();
       
       
       
       
        if (hasBroadcastStream(conn.getScope(), streams[0].toString())) {
            log.info("Connecting to live stream: " + streamName);
           
           
            if (conn instanceof IServiceCapableConnection) {
                ((IServiceCapableConnection) conn).invoke("onBroadcast", new Object[]{streamName}, this);
               
                log.info("sending notification to "+conn);
            }
           
        }

    }


howqever im unsure how to get the current client and invoke a method to them only this seems to constantly repeat itself its kinda working, it just keeps looping and invoking the method :\ There will be only one live show at a time so ive set it to the first array key.


let me know.




_______________________________________________
Red5 mailing list
[email protected]
http://osflash.org/mailman/listinfo/red5_osflash.org

Reply via email to