View Full Version : Check stream name server side
mainegate
03-14-2009, 02:14 PM
Anyone know if you can check the stream name on the server side? I want to check an allowed list of stream names to make sure they can use the swf and Flash media encoder.
lg101
03-15-2009, 08:46 AM
Yes, you can check the stream name by using, Stream.name
function getStreamName(myStream){
return myStream.name;
}
mainegate
03-16-2009, 08:13 PM
I have put that server side but I'm not getting it to work...when I have the user publish I put this after it...
nc.call("getStreamName", null);
I'm getting this error message from the server..'Sending error message: Method not found (getStreamName).'
If I trace out Stream.name without publishing it traces "Stream".
Any idea?
vivansarai
03-17-2009, 05:35 AM
Hi mainegate;
For using Stream.name property, we need to use Stream Object which is being published. Supppose if you are publishing/playing a Stream on Server Side
Ex:
var stream = Stream.get("LiveStream");
stream.play("Foo",0,-1); //playing the local file Foo.flv on sever side.
trace("Stream Name is :: "+stream.name); //You should be getting "Stream Name is :: LiveStream".
Case 2: If you want to check for the Stream name with which, Client is Publishing.
For this use ::
application.onPublish(clientObject, streamObject)
{
trace("Stream name :: "+streamObject.name); // This should trace the name of the stream with whihc Client is publishing .
}
Note: application.onPublish(clientObj,streamObj) is event which gets triggered only when client Publishes a stream. So If you want to strore the name of the stream then one need to create a global variable to store it.
Hope this helps..
More detail about Stream.name property :
StreamObject.name
Read-only; contains a unique string associated with a live stream. You can use this property as an index to find a stream within an application on Server Side.
Availability
Flash Communication Server 1
Example
The following function takes a Stream object as a parameter and returns the name of the stream:
function getStreamName(myStream){
return myStream.name;
}
-Vivansa
mainegate
03-17-2009, 02:22 PM
Thanks a lot. I can finally trace out the stream name! I did the second approach.
What I'm trying to do is make sure people cannot stream unless it their id...so say my id is 317....when I publish my stream I call the stream 317. I am trying to only connect 317. I tried the following but it is not disconnecting. myStream.name traces out to 317.
application.onPublish = function(clientObj, myStream)
{
trace("Now streaming: " + myStream.name);
if(myStream.name != "317")
{
application.disconnect(this.client);
}
};
mainegate
03-17-2009, 02:42 PM
Well I got it to work...however I just realized that it actually publishes it before it unpublishes it...anyway around that?
if(myStream.name != "317")
{
application.disconnect(clientObj);
}
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.