|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objectcom.wowza.wms.plugin.flashremoting.FlashRemoteSession
public class FlashRemoteSession
FlashRemoteSession: Main interface into Flash Remoting API. The remote calls can either be make synchronously (the default) or asynchronously (by call FlashRemoteSession.setAsynchronous(true)). In synchronous mode FlashRemoteSession.flush() must be called to send the request to the remote server. In asynchronous mode requests are sent immediately but responses are delivered asynchronously using the virtual host handler thread pool.
Here is an example of a synchronous session:
String url = "http://localhost/amfphp/gateway.php";
FlashRemoteSession remoteSession = FlashRemoteSession.createInstance(appInstance.getVHost(), url);
class MyResponse implements IFlashRemoteResponse
{
public void onFailure(String handlerName, int statusCode, String responseMsg)
{
System.out.println("MyResponse.onFailure["+handlerName+"]: "+statusCode+":"+responseMsg);
}
public void onResult(String handlerName, AMFData res)
{
System.out.println("MyResponse.onResult["+handlerName+"]: "+(res==null?"null":res.toString()));
}
}
IFlashRemoteResponse responseHandler = new MyResponse();
remoteSession.call("HelloWorld.say", responseHandler, "My First Hello World Message");
remoteSession.call("Counter.increment", responseHandler);
remoteSession.call("DataGrid.getDataSet", responseHandler);
remoteSession.flush();
remoteSession.call("HelloWorld.say", responseHandler, "My Second Hello World Message");
remoteSession.call("Counter.increment", responseHandler);
remoteSession.flush();
remoteSession.close();
An asynchronous session looks like this:
String url = "http://localhost/amfphp/gateway.php";
FlashRemoteSession remoteSession = FlashRemoteSession.createInstance(appInstance.getVHost(), url);
class MyResponse implements IFlashRemoteResponse
{
public void onFailure(String handlerName, int statusCode, String responseMsg)
{
System.out.println("MyResponse.onFailure["+handlerName+"]: "+statusCode+":"+responseMsg);
}
public void onResult(String handlerName, AMFData res)
{
System.out.println("MyResponse.onResult["+handlerName+"]: "+(res==null?"null":res.toString()));
}
}
IFlashRemoteResponse responseHandler = new MyResponse();
remoteSession.call("HelloWorld.say", responseHandler, "My First Hello World Message");
remoteSession.call("Counter.increment", responseHandler);
remoteSession.call("DataGrid.getDataSet", responseHandler);
remoteSession.call("HelloWorld.say", responseHandler, "My Second Hello World Message");
remoteSession.call("Counter.increment", responseHandler);
remoteSession.flush();
Field Summary | |
---|---|
static String |
APPENDTOURL
|
static int |
CRLFTEST
|
Constructor Summary | |
---|---|
FlashRemoteSession()
|
Method Summary | |
---|---|
void |
addHTTPHeader(String key,
String value)
Add an HTTP header to all future HTTP requests. |
java.util.Set<String> |
addHTTPHeaderNames()
Get a list of the HTTP header names |
void |
addListener(IFlashRemotingNotify listener)
Add a listener to this session (see IFlashRemotingNotify) |
void |
call(String handlerName,
IFlashRemoteResponse response,
Object... params)
Call a remote method |
void |
call(String handlerName,
Object... params)
Call a remote method |
void |
close()
Close this session |
static FlashRemoteSession |
createInstance(com.wowza.wms.vhost.IVHost vhost,
String url)
Creates a new Flash Remote session that uses the sources of vhost and connects to the server specified by url. |
void |
flush()
Flush the current calls. |
int |
getConnectionTimeout()
Get the HTTP connection timeout (milliseconds) |
String |
getHTTPHeader(String key)
Get an HTTP header value |
boolean |
isAsynchronous()
Return true is session is asynchronous |
void |
removeListener(IFlashRemotingNotify listener)
Remove a listener to this session (see IFlashRemotingNotify) |
void |
run()
Internal for asynchronous operation |
void |
setAsynchronous(boolean asynchronous)
Set the session to be either synchronous or asynchronous (default is false) |
void |
setConnectionTimeout(int connectionTimeout)
Set the HTTP connection timeout (milliseconds) |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String APPENDTOURL
public static final int CRLFTEST
Constructor Detail |
---|
public FlashRemoteSession()
Method Detail |
---|
public void addHTTPHeader(String key, String value)
key
- header namevalue
- header valuepublic java.util.Set<String> addHTTPHeaderNames()
public void addListener(IFlashRemotingNotify listener)
listener
- listenerpublic void call(String handlerName, IFlashRemoteResponse response, Object... params)
handlerName
- method nameresponse
- response handlerparams
- parameterspublic void call(String handlerName, Object... params)
handlerName
- method nameparams
- parameterspublic void close()
public static FlashRemoteSession createInstance(com.wowza.wms.vhost.IVHost vhost, String url)
vhost
- virutal hosturl
- remote url
public void flush()
public int getConnectionTimeout()
public String getHTTPHeader(String key)
key
- header name
public boolean isAsynchronous()
public void removeListener(IFlashRemotingNotify listener)
listener
- listenerpublic void run()
run
in interface Runnable
public void setAsynchronous(boolean asynchronous)
asynchronous
- is asynchronouspublic void setConnectionTimeout(int connectionTimeout)
connectionTimeout
- HTTP connection timeout (milliseconds)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |