I’m trying to use a remote shared object to send data messages between the client and server using the sharedobject.send method for a chat application.
I am really having difficulty understanding the documentations. The code i attempted to use simply didn’t work.
Can someone be kind enough to show me the relevant API calls? And, take a close inspection at my code and tell me were exactly i am going wrong?
Thank You.
Client-Side
import flash.net.NetConnection;
import flash.events.NetStatusEvent;
import flash.events.SyncEvent;
var nc:NetConnection = new NetConnection();
nc.connect(“rtmfp://fms/exampledomain”);
nc.addEventListener(NetStatusEvent.NET_STATUS, netHandler);
function netHandler(event:NetStatusEvent):void{
if(event.info.code == “NetConnection.Connect.Success”){
trace(“Your Connected”);
//Creating the sharedobject
var my_so:SharedObject = SharedObject.getRemote(“users”, nc.uri, false);
my_so.connect(nc);
my_so.addEventListener(SyncEvent.SYNC, syncHandler);
my_so.setProperty(“users”);
my_so.setDirty(“users”);
function syncHandler(event:SyncEvent):void{
var changelist:Array = event.changeList;
}
my_so.send function sendMessage(str){
Server-Side
application.onConnect(clientObj)(){
application.acceptConnection(clientObj){
trace(“connected up”);
}
var my_so = SharedObject.getRemote(“users”, false);
my_so.send(“Hello user”, “Its only a test”);
}