[Red5] Livestreaming: Check if a user is already publishing !
Andy Shaules
bowljoman at hotmail.com
Wed May 13 08:49:33 PDT 2009
and if all else fails, set netconnection andshared object default
AMFObjectEncoding to AMF0
----- Original Message -----
From: "Richard Alam" <ritzalam at gmail.com>
To: <red5 at osflash.org>
Sent: Wednesday, May 13, 2009 8:38 AM
Subject: Re: [Red5] Livestreaming: Check if a user is already publishing !
> Hi,
>
> Not an ideal solution, but you can have your "latecomer" query for the
> status of each user when he joins.
>
> ANother way would be to store user information on the server and have
> the "latecomer" call a service to get all user information.
>
> R
>
> On Wed, May 13, 2009 at 9:29 AM, Mathias Menrath
> <MenrathMathias at t-online.de> wrote:
>> Hi Richard,
>> yes I'm already updating the AV-Components of the receivers as soon as
>> the sender starts publishing by calling such methods on my shared object,
>> and this is working indeed, BUT the big problem is, that this only works
>> when the second user (where the receiver-panel has to be updated)
>> is already logged in before the first user (sender) starts publishing.
>> So it would only work fine when all users would first log in (wait for
>> all
>> other participants to log in) and then afterwards start the AV-streaming
>> one after the other.
>> But of course, i would like to have the components updated from the
>> beginning
>> on, so when the receiver components of a new user, who has just logged
>> in,
>> are included for the first time. I hope you understand what i mean!
>> Here are my two shared object methods for updating the AV-components
>> of all current receivers:
>>
>> public function updateReceiverComponent_streaming(identifier:String):void
>> {
>> if (userStreamMap[identifier].isSender == false)
>> {
>> userStreamMap[identifier].btnAV.enabled = true;
>> userStreamMap[identifier].title += "-> ON AIR";
>> userStreamMap[identifier].setStyle("backgroundColor", "yellow");
>> }
>> }
>>
>> public function
>> updateReceiverComponent_notStreaming(identifier:String):void
>> {
>> if (userStreamMap[identifier].isSender == false)
>> {
>> userStreamMap[identifier].btnAV.enabled = false;
>> userStreamMap[identifier].title =
>> userStreamMap[identifier].userItem.username+" CAM";
>> userStreamMap[identifier].setStyle("backgroundColor", "white");
>> }
>> }
>>
>> As you can see:
>> I'm using an associative Array in Flex (userStreamMap) to store all
>> AV-Components (= own actionscript-class)
>> of the currently logged in users.
>> These AV-components are created within the SyncHandler method of my
>> sharedObject (shared object that stores
>> all current user IDs and their corresponding usernames) dynamically, and
>> also their values are getting set there.
>> This looks like:
>>
>> private
>> function soChatSyncHandler( event:SyncEvent ):void
>> {
>> var results:Object = event.target.data;
>>
>> newUsersArray =
>> new Array();
>>
>> for
>> ( var a:String in results )
>> {
>> userObject =
>> new Object();
>> userObject.username = results[ a ];
>> userObject.userID = a;
>> newUsersArray.push( userObject );
>> }
>>
>> ...
>>
>> for
>> (var i:uint = 0; i < newUsersArray.length; i++)
>> {
>> var currentUser:Object = newUsersArray[i];
>>
>> myAVComponent =
>> new AVComponent();
>> myAVComponent.nc =
>> this.nc;
>> myAVComponent.soChat =
>> this.soChat;
>> myAVComponent.isSender = (currentUser.username == txtGuestName.text
>> || currentUser.username == txtAdminName.text);
>> myAVComponent.userItem = currentUser;
>> myAVComponent.id = currentUser.userID;
>>
>> // store the AV-Component in the associative array !
>> userStreamMap[currentUser.userID] = myAVComponent;
>>
>> if (userStreamMap[currentUser.userID].isSender == true)
>> {
>> AVBox.addChildAt(userStreamMap[currentUser.userID], 0);
>> }
>> else
>> {
>> AVBox.addChild(userStreamMap[currentUser.userID]);
>> }
>> }
>>
>> ...
>> }
>>
>> Within each of these AV-Components, i differentiate bewteen Sender and
>> Receiver, and when the Sender presses
>> the AV-Button and starts publishing, he calls:
>> soChat.send(
>> "updateReceiverComponent_streaming", userItem.userID); //soChat is my
>> sharedObject
>>
>> And when he stopps publishing he calls:
>> soChat.send("updateReceiverComponent_notStreaming", userItem.userID);
>>
>> Hopefully you can now understand what i wanted to achieve.
>>
>>
>>
>>
>> ----- Original Message -----
>> From: "Richard Alam" <ritzalam at gmail.com>
>> To: <red5 at osflash.org>
>> Sent: Wednesday, May 13, 2009 2:37 AM
>> Subject: Re: [Red5] Livestreaming: Check if a user is already publishing
>> !
>>> Are your receivers chacking the property in you SynchEventHandler?
>>>
>>> How about instead of setting a property, you call a method on you shared
>>> object.
>>> Your sender calls:
>>>
>>> so.send("iampublishing", myUserId);
>>>
>>> And in you receiver:
>>>
>>> public function iampublishing(publisherUserId:int):void {
>>> if (myUserId == publisherUserId) {
>>> // I am publishing
>>> btnAV.enabled = true;
>>> } else {
>>> // Somebody else is publishing
>>> btnAV.enabled = false;
>>> }
>>> }
>>>
>>> HTH.
>>>
>>> On Tue, May 12, 2009 at 8:09 PM, Mathias Menrath
>>> <MenrathMathias at t-online.de> wrote:
>>>> I give up. The userID between sender and receiver is equal, too.
>>>> I can see the property in the persistent shared object, and when I'm
>>>> testing it with only 1 client ( set the property and then check it
>>>> directly
>>>> afterwards ), it works. But for unknown reasons, I am not able to check
>>>> the property with another client (who didn't call "so.setProperty"
>>>> before).
>>>>
>>>> Thanks for all your answers anyway.
>>>> Maybe this problem has got a technical background (AMF-type,
>>>> RED5-version,
>>>> ...)
>>>> and is therefore beyond my knowledge... who knows...
>>>>
>>>> ----- Original Message -----
>>>> From: Andy Shaules
>>>> To: red5 at osflash.org
>>>> Sent: Tuesday, May 12, 2009 7:12 PM
>>>> Subject: Re: [Red5] Livestreaming: Check if a user is already
>>>> publishing
>>>> !
>>>> then it sounds like userID is not equal between the sender and
>>>> reciever.
>>>>
>>>>
>>>>
>>>> ----- Original Message -----
>>>> From: Mathias Menrath
>>>> To: red5 at osflash.org
>>>> Sent: Tuesday, May 12, 2009 9:51 AM
>>>> Subject: Re: [Red5] Livestreaming: Check if a user is already
>>>> publishing
>>>> !
>>>> oops,
>>>> this was just the older version of the code snippet, that I copied and
>>>> pasted
>>>> from the bottom of this mail.
>>>> Of course, in my current version, the persistence- property is set to
>>>> "true"
>>>> !
>>>> But it doesn't work either.
>>>> ;-(
>>>>
>>>> ----- Original Message -----
>>>> From: Andy Shaules
>>>> To: red5 at osflash.org
>>>> Sent: Tuesday, May 12, 2009 6:12 PM
>>>> Subject: Re: [Red5] Livestreaming: Check if a user is already
>>>> publishing
>>>> !
>>>> "soStream = SharedObject.getRemote( "streamlist", nc.uri, false );"
>>>>
>>>> Means not persitant.
>>>>
>>>>
>>>>
>>>> Depending on who connects first, it will be undefined for the reciever.
>>>>
>>>>
>>>>
>>>>
>>>> ----- Original Message -----
>>>> From: Mathias Menrath
>>>> To: red5 at osflash.org
>>>> Sent: Tuesday, May 12, 2009 8:57 AM
>>>> Subject: Re: [Red5] Livestreaming: Check if a user is already
>>>> publishing
>>>> !
>>>> @Andy, Walter: Thanks for your help so far!
>>>>
>>>> I have now realized that when the Sender - who has set the property by
>>>> calling
>>>> so.setProperty(userID, "publishing") - checks this property afterwards
>>>> by
>>>> calling
>>>> the following query, it works fine:
>>>>
>>>> if
>>>> (so.data[userID] == "publishing")
>>>>
>>>> {
>>>> // these lines get called!
>>>> ..
>>>> }
>>>>
>>>> But when i make the same query on another client (Receiver), the
>>>> property
>>>> seems
>>>> to be undefined, and therefore i cannot check it.
>>>> And that is exactly the point that I completely don't understand.
>>>>
>>>> Every client sets up the connection to the shared-object via the
>>>> following
>>>> lines:
>>>>
>>>> soStream = SharedObject.getRemote( "streamlist", nc.uri, false );
>>>> soStream.addEventListener( NetStatusEvent.NET_STATUS,
>>>> soStreamNetStatusHandler );
>>>> soStream.addEventListener( AsyncErrorEvent.ASYNC_ERROR,
>>>> soStreamAsyncErrorHandler );
>>>> soStream.addEventListener( SyncEvent.SYNC, soStreamSyncHandler );
>>>> soStream.client = this;
>>>> soStream.connect( nc );
>>>>
>>>>
>>>> ----- Original Message -----
>>>> From: Andy Shaules
>>>> To: red5 at osflash.org
>>>> Sent: Tuesday, May 12, 2009 3:34 AM
>>>> Subject: Re: [Red5] Livestreaming: Check if a user is already
>>>> publishing
>>>> !
>>>> oops 'undefined' is a key word and should not be in quotes
>>>>
>>>> ----- Original Message -----
>>>> From: Andy Shaules
>>>> To: red5 at osflash.org
>>>> Sent: Monday, May 11, 2009 6:27 PM
>>>> Subject: Re: [Red5] Livestreaming: Check if a user is already
>>>> publishing
>>>> !
>>>> There is also the possibility of undefined.
>>>>
>>>> As well check your p's and q's for simple typo's such as ...
>>>>
>>>> so.data[userId]
>>>>
>>>> ...is not the same as...
>>>>
>>>> so.data.userId
>>>>
>>>> ...when userId:String is not actually equal to 'userId'.
>>>>
>>>> When checking and setting property names of a shared object via
>>>> variables,
>>>> it is not uncommon to mix up data.StringVar and data[StringVar].
>>>> Double check bothe sender and reciever setter/getters of the so
>>>> properties.
>>>> function checkSo( so:SharedObject,userId:String):void
>>>> {
>>>>
>>>> if (so.data[userId] == "publishing")
>>>> ;
>>>> else if (so.data[userId] == "notPublishing")
>>>> ;
>>>> else if (so.data[userId] == "undefined")
>>>> so.setProperty(userId,"notPublishing" )
>>>>
>>>> }
>>>>
>>>> Andy
>>>>
>>>> ----- Original Message -----
>>>> From: Mathias Menrath
>>>> To: red5 at osflash.org
>>>> Sent: Monday, May 11, 2009 6:00 PM
>>>> Subject: Re: [Red5] Livestreaming: Check if a user is already
>>>> publishing
>>>> !
>>>> I still don't get it working!
>>>> I tried it with a persistent shared object, and though i can see the
>>>> entry
>>>> in that shared object,
>>>> i am not able to check the current value of the specific property!
>>>> So the following lines simply don't work for me:
>>>>
>>>> if (soStream.data[userID] == "publishing")
>>>> ...
>>>> if (soStream.data[userID] == "notPublishing")
>>>>
>>>> As I already mentioned, the crazy thing is, that the property (userID)
>>>> does
>>>> exist in that persistent
>>>> shared object, but the above queries still don't work.
>>>> What am I doing wrong here?
>>>>
>>>>
>>>> ----- Original Message -----
>>>> From: Mathias Menrath
>>>> To: red5 at osflash.org
>>>> Sent: Monday, May 11, 2009 11:19 PM
>>>> Subject: Re: [Red5] Livestreaming: Check if a user is already
>>>> publishing
>>>> !
>>>> Hi Walter,
>>>>
>>>> thanks for your answer.
>>>> However, your solution would only work for a Java-based Client or for
>>>> the
>>>> RED5-server-application
>>>> itself. But in my case, i use a Flex-Client. That's why i define a new
>>>> property for the sharedObject
>>>> by the "setProperty"-method (clientside way).
>>>> The serverside part of my sharedObject is:
>>>>
>>>> /**SharedObject
>>>> for streaming informations. */
>>>> private ISharedObject streamSo;
>>>> ...
>>>>
>>>> createSharedObject(
>>>> myScope, "streamlist", false);
>>>> streamSo = getSharedObject(myScope, "streamlist");
>>>>
>>>> I'm at a loss here.
>>>> Any further hint would be greatly appreciated.
>>>>
>>>> Mathias
>>>>
>>>>
>>>> ----- Original Message -----
>>>> From: Walter Tak
>>>> To: red5 at osflash.org
>>>> Sent: Monday, May 11, 2009 8:54 PM
>>>> Subject: Re: [Red5] Livestreaming: Check if a user is already
>>>> publishing
>>>> !
>>>> Try to change: if (soStream.data.id == "notPublishing")
>>>>
>>>> to:
>>>>
>>>> if (soStream.data.id.equals("notPublishing") );
>>>>
>>>>
>>>> See
>>>> http://leepoint.net/notes-java/data/expressions/22compareobjects.html
>>>>
>>>> Walter
>>>>
>>>> ----- Original Message -----
>>>> From: Mathias Menrath
>>>> To: red5 at osflash.org
>>>> Sent: Monday, 11 May 2009 18:15
>>>> Subject: [Red5] Livestreaming: Check if a user is already publishing !
>>>> Hi,
>>>> i want to use a Remote Shared Object to store the information if a
>>>> specific
>>>> user
>>>> (with an unique user ID) is currently publishing or not, so that the
>>>> "Play"-Button for
>>>> all the other Receivers is getting enabled or disabled within the
>>>> corresponding Video-
>>>> Component.
>>>> I thought i could simply do the following:
>>>>
>>>> 1. Setup the SharedObject for the streaming informations:
>>>>
>>>> soStream = SharedObject.getRemote(
>>>> "streamlist", nc.uri, false );
>>>> soStream.addEventListener( NetStatusEvent.NET_STATUS,
>>>> soStreamNetStatusHandler );
>>>> soStream.addEventListener( AsyncErrorEvent.ASYNC_ERROR,
>>>> soStreamAsyncErrorHandler );
>>>> soStream.addEventListener( SyncEvent.SYNC, soStreamSyncHandler );
>>>> soStream.client =
>>>> this;
>>>> soStream.connect( nc );
>>>>
>>>> 2. Within my Video-Component: set the property for the sharedObject (as
>>>> Sender) ..
>>>> ... and check this property
>>>> (as Receiver)
>>>>
>>>> // "id" is a unique user ID (type String)
>>>>
>>>> As Sender: soStream.setProperty(id, "notPublishing"); // by default
>>>> soStream.setProperty(id, "publishing"); // when
>>>> publishing
>>>>
>>>> As Receiver:
>>>> if (soStream.data.id == "notPublishing")
>>>> {
>>>> btnAV.enabled = false;
>>>> }
>>>> else if (soStream.data.id == "publishing")
>>>> {
>>>> btnAV.enabled = true;
>>>> title += "-> ON AIR";
>>>> setStyle("backgroundColor", "yellow")
>>>> }
>>>>
>>>> However: Neither the first if-block (blue) nor the second one (green)
>>>> are
>>>> getting called !!!
>>>> Though the data in the sharedObject is definately getting set
>>>> by the Sender.
>>>>
>>>> Any ideas what could be the problem here ?
>>>>
>>>> Greetz
>>>>
>>>> Mathias
>>>>
>>>> ________________________________
>>>>
>>>> _______________________________________________
>>>> Red5 mailing list
>>>> Red5 at osflash.org
>>>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>>>
>>>> ________________________________
>>>>
>>>> Internal Virus Database is out-of-date.
>>>> Checked by AVG.
>>>> Version: 7.5.557 / Virus Database: 270.12.11/2089 - Release Date:
>>>> 30-04-09
>>>> 17:53
>>>>
>>>> ________________________________
>>>>
>>>> _______________________________________________
>>>> Red5 mailing list
>>>> Red5 at osflash.org
>>>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>>>
>>>> ________________________________
>>>>
>>>> _______________________________________________
>>>> Red5 mailing list
>>>> Red5 at osflash.org
>>>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>>>
>>>> ________________________________
>>>>
>>>> _______________________________________________
>>>> Red5 mailing list
>>>> Red5 at osflash.org
>>>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>>>
>>>> ________________________________
>>>>
>>>> _______________________________________________
>>>> Red5 mailing list
>>>> Red5 at osflash.org
>>>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>>>
>>>> ________________________________
>>>>
>>>> _______________________________________________
>>>> Red5 mailing list
>>>> Red5 at osflash.org
>>>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>>>
>>>> ________________________________
>>>>
>>>> _______________________________________________
>>>> Red5 mailing list
>>>> Red5 at osflash.org
>>>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>>>
>>>> ________________________________
>>>>
>>>> _______________________________________________
>>>> Red5 mailing list
>>>> Red5 at osflash.org
>>>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>>>
>>>> ________________________________
>>>>
>>>> _______________________________________________
>>>> Red5 mailing list
>>>> Red5 at osflash.org
>>>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>>>
>>>> ________________________________
>>>>
>>>> _______________________________________________
>>>> Red5 mailing list
>>>> Red5 at osflash.org
>>>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>>>
>>>> _______________________________________________
>>>> Red5 mailing list
>>>> Red5 at osflash.org
>>>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> ---
>>> BigBlueButton
>>> http://www.bigbluebutton.org
>>> http://code.google.com/p/bigbluebutton
>>>
>>> _______________________________________________
>>> Red5 mailing list
>>> Red5 at osflash.org
>>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>>
>> _______________________________________________
>> Red5 mailing list
>> Red5 at osflash.org
>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>
>>
>
>
>
> --
> ---
> BigBlueButton
> http://www.bigbluebutton.org
> http://code.google.com/p/bigbluebutton
>
> _______________________________________________
> Red5 mailing list
> Red5 at osflash.org
> http://osflash.org/mailman/listinfo/red5_osflash.org
>
More information about the Red5
mailing list