• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to connect with Adobe Media Server to random Remote Shared Object

Explorer ,
Oct 07, 2015 Oct 07, 2015

Copy link to clipboard

Copied

Hello, I have my web-based application developed in Flash Professional CC and exported to Flash Player 13.

In my web-based application I have 2 classes: Connection (who creates the connection with my Adobe Media Server) and GlobalObject (who creates the Remote Shared Object).

This is the code that I have:

//Class Connection

import flash.events.AsyncErrorEvent;

import flash.events.Event;

import flash.events.IOErrorEvent;

import flash.events.SecurityErrorEvent;

import flash.events.SyncEvent;

import flash.events.NetStatusEvent;

import flash.net.NetConnection;

import flash.net.ObjectEncoding;

import flash.net.SharedObject;

var nc:NetConnection = new NetConnection();

nc.objectEncoding = ObjectEncoding.AMF3;

nc.client = this;

nc.proxyType = "best";

nc.addEventListener(NetStatusEvent.NET_STATUS, netSAServerRTMPStatus);

nc.addEventListener(IOErrorEvent.IO_ERROR, onIOError);

nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);

nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);

nc.connect("rtmp://myAMS_URL:1935/myApp", "myRandomChannel");

var _ro:GlobalObject;

function onIOError(e:IOErrorEvent):void

{

    trace("onIOError");

}

function asyncErrorHandler(e:AsyncErrorEvent):void

{

    trace("asyncErrorHandler = " + e.error);

}

function onSecurityError(e:SecurityError):void

{

    trace("onSecurityError = " + e.error);

}

function netSAServerRTMPStatus(event:NetStatusEvent):void

{

    switch (info.code)

    {

        case "NetConnection.Connect.Success":

            trace("connected");

            ConnectToSharedObject();

        default:

            trace(e.info.code);

            break;

    }

}

function ConnectToSharedObject():void

{

    _ro = new GlobalObject();

    var randomRO:Number = Math.random();

    _ro.connect(randomRO, nc, false);

    trace(_ro.connected);

    if(_ro.connected == true)

    {

        _ro.addEventListener("onNewMsg", onNewMsg);

        _ro.sendNewMsg("Hello");

    }

}

function onNewMsg(e:Event):void

{

    trace(e.target.chatMsg);

}

//Class GlobalObject

import flash.events.AsyncErrorEvent;

import flash.events.Event;

import flash.events.EventDispatcher;

import flash.events.SyncEvent;

import flash.net.NetConnection;

import flash.net.ObjectEncoding;

import flash.net.SharedObject;

var so:SharedObject;

var connected:Boolean;

var _msg:String;

function GlobalObject()

{

    super();

}

function connect(p_soName:String, p_nc:NetConnection, p_persistant:Boolean):void

{

    // create StoredObject

    so = SharedObject.getRemote(p_soName, p_nc.uri, p_persistant);

    so.client = this;

    // setup the onSync events

    so.addEventListener(SyncEvent.SYNC, onSync);

    // connect to the SO

    so.connect(p_nc);

    connected = true

}

function disconnect():void

{

    so.close();

}

function onSync(evt:SyncEvent):void

{

    trace("onSync");

}

public function sendNewMsg(msg:String):void

{

    so.send("mewMsg", msg);

}

function mewMsg(msg:String):void

{

    _msg = msg;

    dispatchEvent(new Event("onNewMsg", _msg));

}

The problem is that I never receive the "onSync" event, so then I never receive the messages. What I'm doing wrong? What I have to add or modify?

I have no code on the server side (C:\ProgramFiles\Adobe\AdobeMediaServer5\applications\myApp). All this code is compiled and exported to a SWF file, and it's the file that the user loads when go to my webpage.

I hope someon could help me.

Best regards,

Manel

TOPICS
ActionScript

Views

333

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Oct 14, 2015 Oct 14, 2015

Hello,

The problem is fixed! The point was that the AMS folder that I created were defined as "live" by default app.Once I changed this, it works corretly.

Best regards

Votes

Translate

Translate
Explorer ,
Oct 14, 2015 Oct 14, 2015

Copy link to clipboard

Copied

LATEST

Hello,

The problem is fixed! The point was that the AMS folder that I created were defined as "live" by default app.Once I changed this, it works corretly.

Best regards

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines