Responder 클래스는 구체적인 작업의 성공 혹은 실패와 관련에 서버로 부터의 반환값들을 다루기 위해 NetConnection.call()에 사용되는 객체를 제공합니다. NetConnection.call()이 사용이 될 때, 현재 작동에 대한 네트워크 작동의 현재 연결상태, 혹은 현재 연결상태와 관련된 실패가 일어날 수 있습니다. Operation errors는 NetConnection에러 핸들링 대신 Responder객체를 target으로 합니다.

The Responder class provides an object that is used in NetConnection.call() to handle return values from the server related to the success or failure of specific operations. When working with NetConnection.call(), you may encounter a network operation fault specific to the current operation or a fault related to the current connection status. Operation errors target the Responder object instead of the NetConnection object for easier error handling.

 

파라미터(Parameters)

 

result - 서버로 부터 성공&반환값 호출이 있으면 작동되는 함수 (The function invoked if the call to the server succeeds and returns a result)

 

status -  서버가 에러를 반환하면 작동되는 함수(The function invoked if the server returns an error)

 

다음 예제는 NetConnection클래스의 call메소드를 이용해 FMS와 Flex의 Data를 주고 받는 예제입니다.

 

 

 

 

 

 

 

NetConnection클래스의 call메소드 Reference문서를 보면 아래와 같이 나와있습니다.

 

call(command:String, responder:Responder, ... arguments):void
Calls a command or method on Flash Media Server or on an application server running Flash Remoting.

 

첫번째 값으로 서버단에서 실행 할 명령이나 메소드가 들어가고, 두번째 값으로 서버로부터 들어오는 응답을 받기위한 객체인 Responder, 마지막인자로 서버에 보낼 메시지가 들어갑니다. 

 

_nc.call("sendMsg", r, "From Client to Server : My Name is Client. What is your name?");

 

서버의 "sendMsg"에게 "From Client to Server : My Name is Client. What is your name?" 라는 메시지를 보내고, 서버는 다음과 같이 클라이언트로 부터 받은 메시지를 출력합니다.

 

 

 

 

client.sendMsg = function(msg){

        trace(msg);

        return "From Server to Client : Hello Client, My Name is Server";

    };

 

서버는 "From Server to Client : Hello Client, My Name is Server" 라는 메시지를 클라이언트에게 보냅니다.  클라이언트의 Responder인스턴스인 r이 서버에서 보낸 메시지를 받은 후, 출력합니다.

 

*source code : NetConnectionCallExample.fxp

AND