You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "sh_apache (JIRA)" <ji...@apache.org> on 2014/04/01 10:20:21 UTC

[jira] [Comment Edited] (THRIFT-1223) AS3 extension - Socket IO, asnychronous calls, callbacks

    [ https://issues.apache.org/jira/browse/THRIFT-1223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13956223#comment-13956223 ] 

sh_apache edited comment on THRIFT-1223 at 4/1/14 8:19 AM:
-----------------------------------------------------------

can you give a detailed example ?
I need connect as3 to java by thrift, and want use TSocket. if I use your lib , 
how do I write as3 code?  and is I need generate as3 code by your lib ? is I need chang java code?

Thank you! 


was (Author: sh_apache):
can you give a detailed example ?
I need connect as3 to java by thrift, and want use TSocket. if I use your lib , 
how do I write as3 code?  and is I need generate as3 client code by your lib ? is I need chang java code?

Thank you! 

> AS3 extension - Socket IO, asnychronous calls, callbacks
> --------------------------------------------------------
>
>                 Key: THRIFT-1223
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1223
>             Project: Thrift
>          Issue Type: New Feature
>          Components: AS3 - Compiler, AS3 - Library
>            Reporter: Matthias Einwag
>              Labels: AS3, Async, Compiler, Library
>         Attachments: as3library.zip, as3library.zip, t_as3_generator.cc, thrift.zip
>
>
> Hi everyone,
> first of all I'm new to Thrift and JIRA, so I hope I can get this right. 
> I will try to attach my modified version of the AS3 generator and the AS3 libs.
> I did some work on the AS3 implementation of thrift to get TCP/IP socket support. This includes a new transport TSocket.
> Because actionscript supports only non-blocking IO you must use TFramedTransport, which is also added and wraps around TSocket.
> Some example code to create a framed transport:
> private var socket:Socket;
> private var transport:TIOStreamTransport;
> private var framedTransport:TFramedTransport;
> socket = new Socket("127.0.0.1",9090);
> transport = new TSocket(socket);
> transport.open();
> framedTransport = new TFramedTransport(transport);
> As I did not like the current asynchronous implementation of Thrift/AS3, I did some further changes:
> - For each service function a send function and a receive function is generated
> - The send function sends the data over the transport and creates an AsyncResult object (similar to the Deferred in the Py-Twisted implementation), which stores error and success callback functions as well as the corresponding receive function. I would also like to add a timeout timer later to this.
> - I now use a processor object for clients and servers. The processor registers at the transport and is notified when a new Frame was received. Then process() is called which decodes one message. The processor has a dictionary that contains the sent requests (TAsyncResult objects). If a response message is requested the processor calls the recveive function for the request, which will then lead to a success or error call. This is not similar to the Java and Py-Twisted implementation where the sequence id and dictionary is stored in the client. But I find it more useful because I can support callbacks (see later).
> - The generic implementation TProcessor can be used to support client only functionality.
> Example:
> protocol = new TBinaryProtocol(framedTransport);
> processor = new TProcessor(protocol);	
> client = new ServiceClient(processor);
> TAsyncResult ar = client.send_doSomething(successHandler,errorHandler);
> - Derived processors are used for server side functionality and callbacks
> Example:
> service = new ServiceProcessor(theComponentThatImplementsTheServiceInterface,protocol);
> Now this type of processor can be used to send requests (creating a client as seen above) and meanwhile will also process incoming requests for the specified service.
> I need to use this for callbacks (events that are sent spontaneously from the server to the actionscript client)
> Missing:
> - Improved error handling. At the moment the as3 client does not detect if the server disconnect, only if it sends a request.
> - "Real" server side functionality. Would need a serversocket that creates a new serviceProcessor for each client that connects.
> - The older HTTP transports are currently not compatible. They have to be changed to the new processor usage and must send a TMessageReceivedEvent to the processor. Maybe some minor changes I could add, but I have no time to test HTTP.



--
This message was sent by Atlassian JIRA
(v6.2#6252)