RemoteObjectAMF0 update

Posted on May 18, 2006 | 11 comments

Thanks to Xavi Beumaia’s post about his updates to his AMF0 Flex2B3 class I have been able to update the last part of the RemoteObjectAMF0 class.

I was missing the functionality to pass along the parameters to the function call, regardless of how many parameters where present. Before I just had hard coded it to 3. I have also updated some message handling on the Fault event.

I believe now its ready for some testing and real usage. If you end up using it in an application give me the heads up.

You can find the example and source code here.

  • http://arielon.wordpress.com ariel

    Just going to give it a try….

  • http://www.drumbeatinsight.com judah

    Thanks for this example! I have been looking for a login in php like this.

    My eventual goal is to have a login for Flex 2 and php that has md_5 encryption, session management and will timeout. I haven’t looked too deep into the example code but didn’t see it.

    I still don’t know how to approach this for Flex 2. It was easier in Flash. Any suggestions or upgrade plans? Or something explaining what you would do?

    Thanks again for this! It helps tons! :)

  • http://www.renaun.com Renaun Erickson

    There are some classes available in the “corelib” library that you can use in connection to the MD5 hashing of the password. Maybe I’ll get some time and update the example to show the basic password hashing and checking on the back end.

  • Pingback: John C. Bland II on *

  • andi

    I also used this class in my project, and I liked it wery much.
    The only thing I wasn’t able to use is class mappings (nither with amfphp +php nor with openamf+java) in either way.
    Should it work? I just need to keep trying?
    Thanks a lot

  • http://www.renaun.com Renaun Erickson

    I have not tried to narrow down class mapping issues. I know that people talk about class mapping issues on AMFPHP list. I’ll post more if I come across some information.

  • andi

    I have been playing with class mappings, and I just want you to let you know that with AMFPHP it works in both ways (AS -> PHP and PHP->AS) :).

    Another question. What about authentication with RemoteObjectAMF0? The setCredentials() method shoud be used and this is a method of AbstractService, but RemoteObjectAMF0 extends from Proxy (AbstractService extends from Proxy too).
    Was there a reason to not inherit from AbstractService?

    I have tried to change it to inherit from AbstractService, it gave me the “Namespace not found” error, but after I added:
    use namespace flash_proxy;
    everything seems to work well. And this way, the ServiceLocator’s getService can be used instead of the getRPCService.
    What do you think?

  • Mike

    Thanks! Using this with Flex 2 and Java POJO’s.

    On some computers if we call a remote function every, say, 200ms, and then do that in a few browser tabs, some of the calls start failing. It doesn’t happen so much on faster computers. Do you know if this can be prevented or what the load issue is that is causing them?

  • http://www.renaun.com Renaun Erickson

    The class is pretty generic just handling dynamic method calling. So it is more likely a server side thing…when you say failing do the requests go out and never come back or do they go out and come back with an error message?

  • Mike

    Sorry for the amount of text, but here are the details:

    1. Yes, the call makes it to the server. I can print statements out showing that the call is made on the server; however, the client gets an error rather than the normal RPC return.

    2. The RemoteObjectAMF0 object has a result handler and a fault handler, but this error event does not go to either of them. The event is actually a “NetStatusEvent” that occurs on the “gateway_conn” public variable of the RemoteObjectAMF0 class. To catch the event I use the following code (assuming gameService is an instance of RemoteObjectAMF0):

    gameService.gateway_conn.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

    The result of the RPC never comes back to the result handler.

    3. This is the text I get when I don’t catch the event:

    Error #2044: Unhandled NetStatusEvent:. level=error, code=NetConnection.Call.Failed

    at com.renaun.rpc::RemoteObjectAMF0/http://www.adobe.com/2006/actionscript/flash/proxy::callProperty()

    at RPCTest/::initApp()

    at RPCTest/___Application1_creationComplete()

    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()

    at flash.events::EventDispatcher/dispatchEvent()

    at mx.core::UIComponent/dispatchEvent()

    at mx.core::UIComponent/set initialized()

    at mx.managers::LayoutManager/::doPhasedInstantiation()

    at Function/http://adobe.com/AS3/2006/builtin::apply()

    at mx.core::UIComponent/::callLaterDispatcher2()

    at mx.core::UIComponent/::callLaterDispatcher()

  • http://www.renaun.com Renaun Erickson

    NetConnection.Call.Failed are usually a server side error. It can’t get to the gateway properly, or there is improper text before the headers/binary stream.

    I’ll look at adding the NetStatusEvent in to the class and pass back a Fault message.

  • Mike

    Ok thanks for the help, appreciated. I can’t get objects serializing yet but when I do if you like I will let you know about our Flex 2 – Java POJO use case.