您可以将 NetStream 用于所有这些,除非它是一个“群”聊天。如果是群聊,你需要共享对象,如果是一对一聊天,你可以使用 NetStream。它会是这样的:
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');
从此,您可以使用如下消息功能互相聊天:
private function message(someMessage:String):void
{
// do something
}
现在您只需要客户端能够发送这样的消息:
stream.send('message', yourMessage);
希望这可以帮助。