0

I created a media server with 'Adobe Media Server Starter 5' on localhost and I am able to connect to it via an AS3 AIR Application. I can see the connection from my Application called 'SimpleServer' in the 'Adobe Media Server Administration Console' and I get a positive feedback about the connection:

Accepted a connection from IP:127.0.0.1, referrer: app:/SimpleServer.swf, pageurl:

I neither get a compile time nor a runtime error when trying to create a new SharedObject, I get no feedback at all. I am using the following code:

    var shared:SharedObject = SharedObject.getRemote("HelloWorld", "rtmp://localhost/SimpleServer");
    shared.addEventListener(SyncEvent.SYNC, syncEventHandler);
    shared.connect(nc);

The NetConnection is created as followed:

    nc = new NetConnection();
    nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
    nc.connect("rtmp://localhost/SimpleServer");
    nc.client = this;

I cannot see a SharedObject in 'View Applications' -> 'Shared Objects' and I get no feedback about the creation. It is like the object has never been created. I also tried to set properties on the SharedObject, with no effect:

shared.setProperty("test", false);

Is there a simple solution to this problem or do I have to configure advanced server stuff? Thank you in advance!

1awuesterose
  • 495
  • 5
  • 15
  • Do either of the event handlers that you add above get executed? Are you waiting for the NetConnection to connect before you call `connect()` on the `SharedObject`? – Sunil D. May 26 '13 at 23:09
  • It seems like the `syncEventHandler` doesn't get executed. The `netStatusHandler` gets executed and indicates the `NetConnection` as connected, so it is connected when trying to connect the `SharedObject`... – 1awuesterose May 27 '13 at 08:48
  • I managed to solve the problem, like I commented on duTr's answer. Thank you for your effort! – 1awuesterose May 27 '13 at 09:12

1 Answers1

0

As Sunil asked in the comments, is syncEventHandler ever called when you run your code?

To partially answer your questions: No you don't need any specific server-side configuration to be able to retrieve a SharedObject on the client side. Simply make sure your connected to the server before performing any attempt at getting/connecting to a remote shared object.

See this answer for some more informations

Besides, a good practive when attempting to get a remote shared object is also to use the uri from your NetConnection instance:

var shared:SharedObject = SharedObject.getRemote("HelloWorld", nc.uri);
Community
  • 1
  • 1
duTr
  • 714
  • 5
  • 21
  • I created the SharedObject on a KeyboardEvent. I changed the variable `shared` to a global one, so it will exist over the whole runtime of the program. Now I can see the SharedObject in the Administration Console. The same effect occurs when I declare `shared` local, but push it onto a global Array or something. I also added the line `shared.client = this`, but I figured out this had no effect. Thank you for your help! – 1awuesterose May 27 '13 at 09:11