开发者

How do I make a single connection to handle video, audio and chat in Flex

I'm developing an application and I want to make one single connection for video (netstream) and chat (sharedObject).

I have one connection for each but I have limited connection available in the server so I need to make a single connection to handle the video net stream and chat sharedObject.

I use these URLs to connect:

private var serverWebcamURL:String = "rtmp://myserverIP/live";
private var server开发者_开发知识库ChatURL:String = "rtmp://myserverIP/multicast/chat";

What do i have to do to make this work?


You could use NetStream for all of those unless it's a 'group' chat. If it's a group chat, you need shared objects, if it's a one on one chat, you can use NetStream. It would be something like this:

var connection:NetConnection = new NetConnection();
connection.connect(yourServerIp);
var stream:NetStream = new NetStream(connection);
stream.receiveAudio(true);
stream.receiveVideo(true);
stream.attachAudio(Microphone.getMicrophone());
stream.attachVideo(Camera.getCamera());
stream.client = this; // Yous should look this up.  This is for client to client communication using a 'handler' within this class
stream.publish('media');
stream.play('media');

And from this, you can chat to each other using a message function like this:

private function message(someMessage:String):void
{
// do something
}

Now you just need the client to be able to send a message like so:

stream.send('message', yourMessage);

Hope this helps.


You could use cuePoints instead of sharedObject for the chat and then use the same connection for everything. I only use Red5, I don't know if it's possible with FMS...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜