RE: [flexcoders] Re: accessing amf3 remote services using netConnection instead of removteObject

2007-04-26 Thread Peter Farland

You can listen at three levels...

 
1. At the service level...
 
remoteObject.addEventListener(ResultEvent.RESULT, resultHandler);
remoteObject.addEventListener(FaultEvent.FAULT, faultHandler);
 
 

2. At the operation/method level...
 
remoteMethod.addEventListener(ResultEvent.RESULT, resultHandler);
remoteMethod.addEventListener(FaultEvent.FAULT, faultHandler);
 


3. At the invocation level...

var asyncToken:AsyncToken = remoteMethod.send();
var responder:IResponder = new Responder(resultHandler, faultHandler);
asyncToken.addResponder(responder);

(You could also bind to the token.result property, but this doesn't help
with faults).





From: flexcoders@yahoogroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of hank williams
Sent: Thursday, April 26, 2007 8:16 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: accessing amf3 remote services
using netConnection instead of removteObject



Mark,

I spoke before I tested, which is always a mistake. I realized I
am not sure, in this scenario, how to set up the event handlers for the
remoteObject in this scenario.

Thanks
Hank


On 4/26/07, Mark Piller <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote: 

Hey Hank,

I know you can invoke a remote object and pass the args
in an array.
We just did this very thing in our data management
implementation.
Here's some reference code:

// create remote object. 
// notice the placeholder for the DESTINATION_NAME
var channelSet:ChannelSet = new ChannelSet();
var channel:Channel = ServerConfig.getChannel( "my-amf"
);
channelSet.addChannel(channel);
var remoteObject:RemoteObject = new RemoteObject(
DESTINATION_NAME );

remoteObject.channelSet = channelSet;

var remoteMethod:AbstractOperation;
// get a reference to the operation. 
remoteMethod=remoteObject.getOperation(
METHOD_YOU_NEED_TO_INVOKE );
// set the arguments. Notice it is an array
remoteMethod.arguments = args;
// invoke the function, get asyncToken
var asyncToken:AsyncToken = remoteMethod.send();

Hope this helps. Let me know if I am not answering your
question :)

Thanks,
Mark

--- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> , "hank williams" <[EMAIL PROTECTED]>
wrote:
>
> Hey Mark,
> 
> No I am really just trying to create a very compact
replacement for
> remoteObject. I want to create a single function that
can do
everything that
> remoteObject does with instantiation setting
destinations and
listeners etc.
> The problem is that actually invoking the remote
function cant be
done with
> an args array with remote object.
> 
> The reason I want to do all of this is to bottleneck
all remoting
calls in
> this library I am building in one place. It is being
ported to an
alternate
> platform and device and all the remoting stuff is
going to have to be
> swapped out so I want to have it exist in one place
and have all the
pieces
> of the code that need it to use this one routine.
Because of the
args issue
> above remoteObject doesnt lend itself to this
strategy.
> 
> Hank
> 
> On 4/26/07, Mark Piller <[EMAIL PROTECTED]> wrote:
> >
> > Hi Hank,
> >
> > Is the end goal to route the invocation via RTMP?
> >
> > Cheers,
> > Mark
> >
> > --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>  ,


"hank
> > williams"  wrote:
> > >
> > > Thanks Sam!
> > >
> > > One question. Is there any way to use the
"destination" concept
since I
 

Re: [flexcoders] Re: accessing amf3 remote services using netConnection instead of removteObject

2007-04-26 Thread hank williams

Mark,

I spoke before I tested, which is always a mistake. I realized I am not
sure, in this scenario, how to set up the event handlers for the
remoteObject in this scenario.

Thanks
Hank

On 4/26/07, Mark Piller <[EMAIL PROTECTED]> wrote:


  Hey Hank,

I know you can invoke a remote object and pass the args in an array.
We just did this very thing in our data management implementation.
Here's some reference code:

// create remote object.
// notice the placeholder for the DESTINATION_NAME
var channelSet:ChannelSet = new ChannelSet();
var channel:Channel = ServerConfig.getChannel( "my-amf" );
channelSet.addChannel(channel);
var remoteObject:RemoteObject = new RemoteObject( DESTINATION_NAME );

remoteObject.channelSet = channelSet;

var remoteMethod:AbstractOperation;
// get a reference to the operation.
remoteMethod=remoteObject.getOperation( METHOD_YOU_NEED_TO_INVOKE );
// set the arguments. Notice it is an array
remoteMethod.arguments = args;
// invoke the function, get asyncToken
var asyncToken:AsyncToken = remoteMethod.send();

Hope this helps. Let me know if I am not answering your question :)

Thanks,
Mark

--- In flexcoders@yahoogroups.com , "hank
williams" <[EMAIL PROTECTED]> wrote:
>
> Hey Mark,
>
> No I am really just trying to create a very compact replacement for
> remoteObject. I want to create a single function that can do
everything that
> remoteObject does with instantiation setting destinations and
listeners etc.
> The problem is that actually invoking the remote function cant be
done with
> an args array with remote object.
>
> The reason I want to do all of this is to bottleneck all remoting
calls in
> this library I am building in one place. It is being ported to an
alternate
> platform and device and all the remoting stuff is going to have to be
> swapped out so I want to have it exist in one place and have all the
pieces
> of the code that need it to use this one routine. Because of the
args issue
> above remoteObject doesnt lend itself to this strategy.
>
> Hank
>
> On 4/26/07, Mark Piller <[EMAIL PROTECTED]> wrote:
> >
> > Hi Hank,
> >
> > Is the end goal to route the invocation via RTMP?
> >
> > Cheers,
> > Mark
> >
> > --- In flexcoders@yahoogroups.com 
,

"hank
> > williams"  wrote:
> > >
> > > Thanks Sam!
> > >
> > > One question. Is there any way to use the "destination" concept
since I
> > > already have all of that defined on the FDS/Server side of things?
> > >
> > > Thanks
> > > Hank
> > >
> > > On 4/26/07, Samuel R. Neff  wrote:
> > > >
> > > >
> > > > It's not well documented, but basically you create a
> > NetConnection, set
> > > > the
> > > > encoding, and run NetConnection.call() where the first param is
> > the fully
> > > > qualified class and method name and remaining params are the
params to
> > > > pass
> > > > on to the server side method.
> > > >
> > > > See classes below (watch wrapping).
> > > >
> > > > HTH,
> > > >
> > > > Sam
> > > >
> > > >
> > > > ---
> > > > We're Hiring! Seeking a passionate developer to join our team
building
> > > > Flex
> > > > based products. Position is in the Washington D.C. metro area. If
> > > > interested
> > > > contact careers@ 
> >
> > > >
> > > >
> > > > package com.atellis.rpc
> > > > {
> > > > import flash.net.*;
> > > > import flash.events.EventDispatcher;
> > > > import flash.events.Event;
> > > > import mx.rpc.AsyncToken;
> > > > import mx.rpc.events.ResultEvent;
> > > >
> > > > public class RemotingServiceBase extends EventDispatcher
> > > > {
> > > > private var _connection:NetConnection;
> > > > private var _remoteClassName:String;
> > > >
> > > > public function RemotingServiceBase(remoteClassName:String,
> > > > encoding:uint = 3) {
> > > >
> > > > _remoteClassName = remoteClassName;
> > > >
> > > > _connection = new NetConnection();
> > > > _connection.objectEncoding = encoding;
> > > > _connection.connect(URLInfo.instance.gatewayUrl);
> > > > }
> > > >
> > > > protected function callService(method:String,
> > > > eventPrefix:String, responder:Function, fault:Function, ...
> > > > rest):AsyncToken
> > > > {
> > > >
> > > > var token:AsyncToken = new AsyncToken(null);
> > > >
> > > > var r:DispatchingResponder = new
> > > > DispatchingResponder(
> > > >
> > > > this,
> > > >
> > > > eventPrefix,
> > > >
> > > > token,
> > > >
> > > > responder,
> > > >
> > > > fault);
> > > >
> > > >
> > > > var a:Array = new Array(rest.length + 2);
> > > > a[0] = _remoteClassName + "." + method;
> > > > a[1] = r;
> > > > var i:uint = 2;
> > > > for each(var o:Object in rest) {
> > > > a[i++] = o;
> > > > }
> > > > _connection.call.apply(_connection, a);
> > > > return token;
> > > > }
> > > >
> > > > }
> > > > }
> > > >
> > > > package com.atellis.rpc
> > > > {
> > > > import flash.net.Responder;
> > > > import flash.events.EventDispatcher;
> > > > import flash.events.Event;
> > > > import mx.rpc.events.ResultEvent;
> > > > import mx.rpc.AsyncToken;
> > > > import mx.rpc.events.FaultEvent

Re: [flexcoders] Re: accessing amf3 remote services using netConnection instead of removteObject

2007-04-26 Thread hank williams

Mark,

Thanks so much. After no one answered earlier in the day I figured there was
just no way to do this. But this is much better than using netConnection.

So get some sleep you midnightcoder :)

Hank

On 4/26/07, Mark Piller <[EMAIL PROTECTED]> wrote:


  Hey Hank,

I know you can invoke a remote object and pass the args in an array.
We just did this very thing in our data management implementation.
Here's some reference code:

// create remote object.
// notice the placeholder for the DESTINATION_NAME
var channelSet:ChannelSet = new ChannelSet();
var channel:Channel = ServerConfig.getChannel( "my-amf" );
channelSet.addChannel(channel);
var remoteObject:RemoteObject = new RemoteObject( DESTINATION_NAME );

remoteObject.channelSet = channelSet;

var remoteMethod:AbstractOperation;
// get a reference to the operation.
remoteMethod=remoteObject.getOperation( METHOD_YOU_NEED_TO_INVOKE );
// set the arguments. Notice it is an array
remoteMethod.arguments = args;
// invoke the function, get asyncToken
var asyncToken:AsyncToken = remoteMethod.send();

Hope this helps. Let me know if I am not answering your question :)

Thanks,
Mark

--- In flexcoders@yahoogroups.com , "hank
williams" <[EMAIL PROTECTED]> wrote:
>
> Hey Mark,
>
> No I am really just trying to create a very compact replacement for
> remoteObject. I want to create a single function that can do
everything that
> remoteObject does with instantiation setting destinations and
listeners etc.
> The problem is that actually invoking the remote function cant be
done with
> an args array with remote object.
>
> The reason I want to do all of this is to bottleneck all remoting
calls in
> this library I am building in one place. It is being ported to an
alternate
> platform and device and all the remoting stuff is going to have to be
> swapped out so I want to have it exist in one place and have all the
pieces
> of the code that need it to use this one routine. Because of the
args issue
> above remoteObject doesnt lend itself to this strategy.
>
> Hank
>
> On 4/26/07, Mark Piller <[EMAIL PROTECTED]> wrote:
> >
> > Hi Hank,
> >
> > Is the end goal to route the invocation via RTMP?
> >
> > Cheers,
> > Mark
> >
> > --- In flexcoders@yahoogroups.com 
,

"hank
> > williams"  wrote:
> > >
> > > Thanks Sam!
> > >
> > > One question. Is there any way to use the "destination" concept
since I
> > > already have all of that defined on the FDS/Server side of things?
> > >
> > > Thanks
> > > Hank
> > >
> > > On 4/26/07, Samuel R. Neff  wrote:
> > > >
> > > >
> > > > It's not well documented, but basically you create a
> > NetConnection, set
> > > > the
> > > > encoding, and run NetConnection.call() where the first param is
> > the fully
> > > > qualified class and method name and remaining params are the
params to
> > > > pass
> > > > on to the server side method.
> > > >
> > > > See classes below (watch wrapping).
> > > >
> > > > HTH,
> > > >
> > > > Sam
> > > >
> > > >
> > > > ---
> > > > We're Hiring! Seeking a passionate developer to join our team
building
> > > > Flex
> > > > based products. Position is in the Washington D.C. metro area. If
> > > > interested
> > > > contact careers@ 
> >
> > > >
> > > >
> > > > package com.atellis.rpc
> > > > {
> > > > import flash.net.*;
> > > > import flash.events.EventDispatcher;
> > > > import flash.events.Event;
> > > > import mx.rpc.AsyncToken;
> > > > import mx.rpc.events.ResultEvent;
> > > >
> > > > public class RemotingServiceBase extends EventDispatcher
> > > > {
> > > > private var _connection:NetConnection;
> > > > private var _remoteClassName:String;
> > > >
> > > > public function RemotingServiceBase(remoteClassName:String,
> > > > encoding:uint = 3) {
> > > >
> > > > _remoteClassName = remoteClassName;
> > > >
> > > > _connection = new NetConnection();
> > > > _connection.objectEncoding = encoding;
> > > > _connection.connect(URLInfo.instance.gatewayUrl);
> > > > }
> > > >
> > > > protected function callService(method:String,
> > > > eventPrefix:String, responder:Function, fault:Function, ...
> > > > rest):AsyncToken
> > > > {
> > > >
> > > > var token:AsyncToken = new AsyncToken(null);
> > > >
> > > > var r:DispatchingResponder = new
> > > > DispatchingResponder(
> > > >
> > > > this,
> > > >
> > > > eventPrefix,
> > > >
> > > > token,
> > > >
> > > > responder,
> > > >
> > > > fault);
> > > >
> > > >
> > > > var a:Array = new Array(rest.length + 2);
> > > > a[0] = _remoteClassName + "." + method;
> > > > a[1] = r;
> > > > var i:uint = 2;
> > > > for each(var o:Object in rest) {
> > > > a[i++] = o;
> > > > }
> > > > _connection.call.apply(_connection, a);
> > > > return token;
> > > > }
> > > >
> > > > }
> > > > }
> > > >
> > > > package com.atellis.rpc
> > > > {
> > > > import flash.net.Responder;
> > > > import flash.events.EventDispatcher;
> > > > import flash.events.Event;
> > > > import mx.rpc.events.ResultEvent;
> > > > import mx.rpc.AsyncToken;
> > > > import mx.rpc.e

[flexcoders] Re: accessing amf3 remote services using netConnection instead of removteObject

2007-04-26 Thread Mark Piller
Hey Hank,

I know you can invoke a remote object and pass the args in an array.
We just did this very thing in our data management implementation.
Here's some reference code:

// create remote object. 
// notice the placeholder for the DESTINATION_NAME
var channelSet:ChannelSet = new ChannelSet();
var channel:Channel = ServerConfig.getChannel( "my-amf" );
channelSet.addChannel(channel);
var remoteObject:RemoteObject = new RemoteObject( DESTINATION_NAME );
 
remoteObject.channelSet = channelSet;

var remoteMethod:AbstractOperation;
// get a reference to the operation. 
remoteMethod=remoteObject.getOperation( METHOD_YOU_NEED_TO_INVOKE );
// set the arguments. Notice it is an array
remoteMethod.arguments = args;
// invoke the function, get asyncToken
var asyncToken:AsyncToken = remoteMethod.send();

Hope this helps. Let me know if I am not answering your question :)

Thanks,
Mark


--- In flexcoders@yahoogroups.com, "hank williams" <[EMAIL PROTECTED]> wrote:
>
> Hey Mark,
> 
> No I am really just trying to create a very compact replacement for
> remoteObject. I want to create a single function that can do
everything that
> remoteObject does with instantiation setting destinations and
listeners etc.
> The problem is that actually invoking the remote function cant be
done with
> an args array with remote object.
> 
> The reason I want to do all of this is to bottleneck all remoting
calls in
> this library I am building in one place. It is being ported to an
alternate
> platform and device and all the remoting stuff is going to have to be
> swapped out so I want to have it exist in one place and have all the
pieces
> of the code that need it to use this one routine. Because of the
args issue
> above remoteObject doesnt lend itself to this strategy.
> 
> Hank
> 
> On 4/26/07, Mark Piller <[EMAIL PROTECTED]> wrote:
> >
> >   Hi Hank,
> >
> > Is the end goal to route the invocation via RTMP?
> >
> > Cheers,
> > Mark
> >
> > --- In flexcoders@yahoogroups.com ,
"hank
> > williams"  wrote:
> > >
> > > Thanks Sam!
> > >
> > > One question. Is there any way to use the "destination" concept
since I
> > > already have all of that defined on the FDS/Server side of things?
> > >
> > > Thanks
> > > Hank
> > >
> > > On 4/26/07, Samuel R. Neff  wrote:
> > > >
> > > >
> > > > It's not well documented, but basically you create a
> > NetConnection, set
> > > > the
> > > > encoding, and run NetConnection.call() where the first param is
> > the fully
> > > > qualified class and method name and remaining params are the
params to
> > > > pass
> > > > on to the server side method.
> > > >
> > > > See classes below (watch wrapping).
> > > >
> > > > HTH,
> > > >
> > > > Sam
> > > >
> > > >
> > > > ---
> > > > We're Hiring! Seeking a passionate developer to join our team
building
> > > > Flex
> > > > based products. Position is in the Washington D.C. metro area. If
> > > > interested
> > > > contact careers@ 
> >
> > > >
> > > >
> > > > package com.atellis.rpc
> > > > {
> > > > import flash.net.*;
> > > > import flash.events.EventDispatcher;
> > > > import flash.events.Event;
> > > > import mx.rpc.AsyncToken;
> > > > import mx.rpc.events.ResultEvent;
> > > >
> > > > public class RemotingServiceBase extends EventDispatcher
> > > > {
> > > > private var _connection:NetConnection;
> > > > private var _remoteClassName:String;
> > > >
> > > > public function RemotingServiceBase(remoteClassName:String,
> > > > encoding:uint = 3) {
> > > >
> > > > _remoteClassName = remoteClassName;
> > > >
> > > > _connection = new NetConnection();
> > > > _connection.objectEncoding = encoding;
> > > > _connection.connect(URLInfo.instance.gatewayUrl);
> > > > }
> > > >
> > > > protected function callService(method:String,
> > > > eventPrefix:String, responder:Function, fault:Function, ...
> > > > rest):AsyncToken
> > > > {
> > > >
> > > > var token:AsyncToken = new AsyncToken(null);
> > > >
> > > > var r:DispatchingResponder = new
> > > > DispatchingResponder(
> > > >
> > > > this,
> > > >
> > > > eventPrefix,
> > > >
> > > > token,
> > > >
> > > > responder,
> > > >
> > > > fault);
> > > >
> > > >
> > > > var a:Array = new Array(rest.length + 2);
> > > > a[0] = _remoteClassName + "." + method;
> > > > a[1] = r;
> > > > var i:uint = 2;
> > > > for each(var o:Object in rest) {
> > > > a[i++] = o;
> > > > }
> > > > _connection.call.apply(_connection, a);
> > > > return token;
> > > > }
> > > >
> > > > }
> > > > }
> > > >
> > > > package com.atellis.rpc
> > > > {
> > > > import flash.net.Responder;
> > > > import flash.events.EventDispatcher;
> > > > import flash.events.Event;
> > > > import mx.rpc.events.ResultEvent;
> > > > import mx.rpc.AsyncToken;
> > > > import mx.rpc.events.FaultEvent;
> > > > import mx.rpc.Fault;
> > > >
> > > > public class DispatchingResponder extends Responder
> > > > {
> > > > private var _eventDispatcher:EventDispatcher;
> > > > private var _eventPrefix:String;
> > > > private var _token

Re: [flexcoders] Re: accessing amf3 remote services using netConnection instead of removteObject

2007-04-26 Thread hank williams

Hey Mark,

No I am really just trying to create a very compact replacement for
remoteObject. I want to create a single function that can do everything that
remoteObject does with instantiation setting destinations and listeners etc.
The problem is that actually invoking the remote function cant be done with
an args array with remote object.

The reason I want to do all of this is to bottleneck all remoting calls in
this library I am building in one place. It is being ported to an alternate
platform and device and all the remoting stuff is going to have to be
swapped out so I want to have it exist in one place and have all the pieces
of the code that need it to use this one routine. Because of the args issue
above remoteObject doesnt lend itself to this strategy.

Hank

On 4/26/07, Mark Piller <[EMAIL PROTECTED]> wrote:


  Hi Hank,

Is the end goal to route the invocation via RTMP?

Cheers,
Mark

--- In flexcoders@yahoogroups.com , "hank
williams" <[EMAIL PROTECTED]> wrote:
>
> Thanks Sam!
>
> One question. Is there any way to use the "destination" concept since I
> already have all of that defined on the FDS/Server side of things?
>
> Thanks
> Hank
>
> On 4/26/07, Samuel R. Neff <[EMAIL PROTECTED]> wrote:
> >
> >
> > It's not well documented, but basically you create a
NetConnection, set
> > the
> > encoding, and run NetConnection.call() where the first param is
the fully
> > qualified class and method name and remaining params are the params to
> > pass
> > on to the server side method.
> >
> > See classes below (watch wrapping).
> >
> > HTH,
> >
> > Sam
> >
> >
> > ---
> > We're Hiring! Seeking a passionate developer to join our team building
> > Flex
> > based products. Position is in the Washington D.C. metro area. If
> > interested
> > contact [EMAIL PROTECTED] 

> >
> >
> > package com.atellis.rpc
> > {
> > import flash.net.*;
> > import flash.events.EventDispatcher;
> > import flash.events.Event;
> > import mx.rpc.AsyncToken;
> > import mx.rpc.events.ResultEvent;
> >
> > public class RemotingServiceBase extends EventDispatcher
> > {
> > private var _connection:NetConnection;
> > private var _remoteClassName:String;
> >
> > public function RemotingServiceBase(remoteClassName:String,
> > encoding:uint = 3) {
> >
> > _remoteClassName = remoteClassName;
> >
> > _connection = new NetConnection();
> > _connection.objectEncoding = encoding;
> > _connection.connect(URLInfo.instance.gatewayUrl);
> > }
> >
> > protected function callService(method:String,
> > eventPrefix:String, responder:Function, fault:Function, ...
> > rest):AsyncToken
> > {
> >
> > var token:AsyncToken = new AsyncToken(null);
> >
> > var r:DispatchingResponder = new
> > DispatchingResponder(
> >
> > this,
> >
> > eventPrefix,
> >
> > token,
> >
> > responder,
> >
> > fault);
> >
> >
> > var a:Array = new Array(rest.length + 2);
> > a[0] = _remoteClassName + "." + method;
> > a[1] = r;
> > var i:uint = 2;
> > for each(var o:Object in rest) {
> > a[i++] = o;
> > }
> > _connection.call.apply(_connection, a);
> > return token;
> > }
> >
> > }
> > }
> >
> > package com.atellis.rpc
> > {
> > import flash.net.Responder;
> > import flash.events.EventDispatcher;
> > import flash.events.Event;
> > import mx.rpc.events.ResultEvent;
> > import mx.rpc.AsyncToken;
> > import mx.rpc.events.FaultEvent;
> > import mx.rpc.Fault;
> >
> > public class DispatchingResponder extends Responder
> > {
> > private var _eventDispatcher:EventDispatcher;
> > private var _eventPrefix:String;
> > private var _token:AsyncToken;
> > private var _responder:Function;
> > private var _fault:Function;
> >
> > public function DispatchingResponder(
> >
> > eventDispatcher:EventDispatcher,
> >
> > eventPrefix:String,
> >
> > token:AsyncToken,
> >
> > responder:Function,
> >
> > fault:Function) {
> > super(doRelay, doFault);
> > _eventDispatcher = eventDispatcher;
> > _eventPrefix = eventPrefix;
> > _responder = responder;
> > _fault = fault;
> > _token = token;
> > }
> >
> > private function doRelay(... rest):void {
> > var event:ResultEvent = new ResultEvent(
> >
> > _eventPrefix + "Result",
> >
> > false,
> >
> > false,
> >
> > rest == null || rest.length != 1 ? rest : rest[0],
> >
> > _token,
> >
> > null);
> >
> >
> > _eventDispatcher.dispatchEvent(event);
> > if (_responder != null) {
> > _responder(event);
> > }
> > }
> >
> > private function doFault(netFault:Object):void {
> > var f:Fault;
> >
> > if(netFault) {
> > var typ:Array = netFault.type.split(".");
> >
> > f = new Fault(typ[typ.length - 1],
> > netFault.description, netFault.details);
> > } else {
> > f = new Fault("Unkown", "An error occurred
> > and no fault details are available", "Unknown");
> > }
> > var event:FaultEvent = new FaultEvent(_eventPrefix +
> > "Fault", false, false, f, _token, null);
> > _eventDispatcher.dispatchEvent(event);
> > if (_fault != null) {
> > _fault(event);
> > }
> > }
> > }
> > }
> >
> > 
> >
> > From: flexco

[flexcoders] Re: accessing amf3 remote services using netConnection instead of removteObject

2007-04-26 Thread Mark Piller
Hi Hank,

Is the end goal to route the invocation via RTMP? 

Cheers,
Mark

--- In flexcoders@yahoogroups.com, "hank williams" <[EMAIL PROTECTED]> wrote:
>
> Thanks Sam!
> 
> One question. Is there any way to use the "destination" concept since I
> already have all of that defined on the FDS/Server side of things?
> 
> Thanks
> Hank
> 
> On 4/26/07, Samuel R. Neff <[EMAIL PROTECTED]> wrote:
> >
> >
> > It's not well documented, but basically you create a
NetConnection, set
> > the
> > encoding, and run NetConnection.call() where the first param is
the fully
> > qualified class and method name and remaining params are the params to
> > pass
> > on to the server side method.
> >
> > See classes below (watch wrapping).
> >
> > HTH,
> >
> > Sam
> >
> >
> > ---
> > We're Hiring! Seeking a passionate developer to join our team building
> > Flex
> > based products. Position is in the Washington D.C. metro area. If
> > interested
> > contact [EMAIL PROTECTED] 
> >
> >
> > package com.atellis.rpc
> > {
> > import flash.net.*;
> > import flash.events.EventDispatcher;
> > import flash.events.Event;
> > import mx.rpc.AsyncToken;
> > import mx.rpc.events.ResultEvent;
> >
> > public class RemotingServiceBase extends EventDispatcher
> > {
> > private var _connection:NetConnection;
> > private var _remoteClassName:String;
> >
> > public function RemotingServiceBase(remoteClassName:String,
> > encoding:uint = 3) {
> >
> > _remoteClassName = remoteClassName;
> >
> > _connection = new NetConnection();
> > _connection.objectEncoding = encoding;
> > _connection.connect(URLInfo.instance.gatewayUrl);
> > }
> >
> > protected function callService(method:String,
> > eventPrefix:String, responder:Function, fault:Function, ...
> > rest):AsyncToken
> > {
> >
> > var token:AsyncToken = new AsyncToken(null);
> >
> > var r:DispatchingResponder = new
> > DispatchingResponder(
> >
> > this,
> >
> > eventPrefix,
> >
> > token,
> >
> > responder,
> >
> > fault);
> >
> >
> > var a:Array = new Array(rest.length + 2);
> > a[0] = _remoteClassName + "." + method;
> > a[1] = r;
> > var i:uint = 2;
> > for each(var o:Object in rest) {
> > a[i++] = o;
> > }
> > _connection.call.apply(_connection, a);
> > return token;
> > }
> >
> > }
> > }
> >
> > package com.atellis.rpc
> > {
> > import flash.net.Responder;
> > import flash.events.EventDispatcher;
> > import flash.events.Event;
> > import mx.rpc.events.ResultEvent;
> > import mx.rpc.AsyncToken;
> > import mx.rpc.events.FaultEvent;
> > import mx.rpc.Fault;
> >
> > public class DispatchingResponder extends Responder
> > {
> > private var _eventDispatcher:EventDispatcher;
> > private var _eventPrefix:String;
> > private var _token:AsyncToken;
> > private var _responder:Function;
> > private var _fault:Function;
> >
> > public function DispatchingResponder(
> >
> > eventDispatcher:EventDispatcher,
> >
> > eventPrefix:String,
> >
> > token:AsyncToken,
> >
> > responder:Function,
> >
> > fault:Function) {
> > super(doRelay, doFault);
> > _eventDispatcher = eventDispatcher;
> > _eventPrefix = eventPrefix;
> > _responder = responder;
> > _fault = fault;
> > _token = token;
> > }
> >
> > private function doRelay(... rest):void {
> > var event:ResultEvent = new ResultEvent(
> >
> > _eventPrefix + "Result",
> >
> > false,
> >
> > false,
> >
> > rest == null || rest.length != 1 ? rest : rest[0],
> >
> > _token,
> >
> > null);
> >
> >
> > _eventDispatcher.dispatchEvent(event);
> > if (_responder != null) {
> > _responder(event);
> > }
> > }
> >
> > private function doFault(netFault:Object):void {
> > var f:Fault;
> >
> > if(netFault) {
> > var typ:Array = netFault.type.split(".");
> >
> > f = new Fault(typ[typ.length - 1],
> > netFault.description, netFault.details);
> > } else {
> > f = new Fault("Unkown", "An error occurred
> > and no fault details are available", "Unknown");
> > }
> > var event:FaultEvent = new FaultEvent(_eventPrefix +
> > "Fault", false, false, f, _token, null);
> > _eventDispatcher.dispatchEvent(event);
> > if (_fault != null) {
> > _fault(event);
> > }
> > }
> > }
> > }
> >
> > 
> >
> > From: flexcoders@yahoogroups.com 
[mailto:
> > flexcoders@yahoogroups.com ] On
> > Behalf Of hank williams
> > Sent: Thursday, April 26, 2007 4:38 PM
> > To: flexcoders@yahoogroups.com 
> > Subject: [flexcoders] accessing amf3 remote services using
netConnection
> > instead of removteObject
> >
> >
> > Does anybody have any example on how to access amf3 remote
services, which
> > need to deal with new concepts like "destination", using a
netConnection
> > call? I am finding that remoteObject doesnt do everything I need.
> >
> > Thanks
> > Hank
> >
> >  
> >
>