|
|
Konuya ilişkin sitenin adresi: http://thanksmister.com/?p=26 Flex, Flash, Air Geriştirme ortamı Flex & Flash Ortam Sunucusu (Media Server) Yazı Söyleşi Uygulaması Gönderildiği tarih Eylül 5, 2006. Flex altındadır Flex Noktalar Mister tarafından hazırlanmıştır. I recently began a new project at work to create a text application for a support service. I wanted to use Flex 2 with the new Flash Media Server 2. I am pretty familiar with Flash Communication Server and have Brian’ Lessers Programming Flash Communication Server. However, with Flex 2, things have change a bit and it took me a while to find a suitable example application (Adobe’s examples are way out of date). Brian Lesser’s site had an updated example that worked for video chat, but it sent messages along the NetStream. I wanted my application to synchronize with the Remote Shared Object, similar to the the Text Chat application found in the development center. Bu örnekte Brain örneği ile başlanmıştır. Flex2 ile kullanılmaya başlanan AMF3 yerine AMF0 kullanılmıştır. Bunun için NetConnection ve SharedObject için kendiniz kod yazmalısınız. NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0; SharedObject.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;Burada kullanıcı bilgileri ağ bağlantısıyla sunucuya gönderilir.
nc.connect("rtmp://localhost/chat_test", userName.text);
Paylaşılan nesnelerin sürekli kalması istenmemiştir. Bunlara doğrudan
bağlantıyla yetinilmiştir.
ro = SharedObject.getRemote("ChatUsers", nc.uri);
Geri dönme yöntemi konuşması, uygulamada toplumsal yöntem içindedir. Bu
nedenle geri dönme nesnesini her nesneye ekleme olanağı vardır.
nc.client = this; ro.client = this;FlexFCS.mxml geri dönme yöntemlerini algılayabilmek için bazı toplumsal islevler eklenmiştir.
/** showMessage is the function called by the SharedObject. */
public function showMessage(msg:String):void{
writeln("showMessage: " + msg + "\n");
}
/** setHistory is the called when the client first connects */
public function setHistory(msg:String):void{
writeln("showHistory: " + msg + "\n");
}
/** msgFromSrvr receives any broadcast messages from connected clients */
public function msgFromSrvr(msg:String):void{
writeMessage(msg);
}
Flash Media Server ile çalışan main.acs Adobe web sitesindekine benzer. ACS
dosyasının üzerine istemci işlevi eklenmiştir. Ayrıca SharedObject adı
değiştirilmiştir.
Tüm kaynak kodlar "FlexChat.zip" olarak sitede bulunmaktadır. |