Tobias,
Yes this is possible with Red5 and OpenLaszlo. Go to this wiki
page<http://wiki.openlaszlo.org/RtmpRed5Webapp>and try the example
war. This page also outlines some bugs in OpenLaszlo
that need fixing in order to support Red5 fully, but it has been working
fine for server - client communication.
Here is an example open laszlo file:
<canvas debug="true">
<button name="callButton" onclick="sendEventCall();">
Call sendEvent
<method name="sendEventCall">
canvas.rtmp.sendEvent.event = "button was clicked!";
canvas.rtmp.sendEvent.call();
</method>
</button>
<rtmpconnection name="rtmp" debug="true" autoconnect="true"
src="rtmpt://192.168.1.134:80/cardsrvr/myhome' }" >
<handler name="onconnect">
Debug.write("connected");
</handler>
<handler name="onerror">
Debug.write("error ",this.status);
</handler>
<netremotecall name="sendEvent" funcname="sendEvent">
<attribute name="event" value="" type="string" />
<netparam name="vars1"><method name="getValue"> return
parent.event;</method></netparam>
</netremotecall>
<netremotecall name="newEvent" funcname="newEvent">
<method name="onResult" args="value">
Debug.write('event received: ' + value);
</method>
</netremotecall>
</rtmpconnection>
</canvas>
This will connect to a red5 rtmpt (http tunneling) connection with the
rtmpconnection tag. Then when the button is clicked
the netremotecall tag named "sendEvent" is used to call the server's
endpoint. The ApplicationAdapter class which is the
server handler for a particular context is used to call into (from client -
server) and call out of (server - client).
public class Application extends ApplicationAdapter implements
IPendingServiceCallback {
private static final Log log = LogFactory.getLog(Application.class);
public boolean appStart() {
log.info("Application.appStart");
return true;
}
public void appStop() {
log.info("Application.appStop");
}
public boolean appConnect(IConnection conn, Object[] params) {
log.info("Application.appConnect " + conn.getClient
().getId());
return true;
}
public void appDisconnect(IConnection conn, Object[] params) {
log.info("Application.appDisconnect " + conn.getClient
().getId());
}
public String sendEvent(String event) {
try {
log.info("Method 'sendEvent' called with: " +
event);
IConnection current = Red5.getConnectionLocal();
Iterator<IConnection> it = current.getScope
().getConnections();
while (it.hasNext()) {
IConnection cons = it.next();
if (cons instanceof
IServiceCapableConnection) {
((IServiceCapableConnection)
cons).invoke("newEvent", new Object[] { event }, this);
}
}
} catch (Exception err) {
log.error("invokeClientFunctions", err);
}
return event;
}
public void resultReceived(IPendingServiceCall call) {
try {
log.info("resultReceived "+call);
log.info("resultReceived Arguments "+call.getArguments());
log.info("resultReceived Arguments Number
"+call.getArguments().length);
log.info("resultReceived Result "+call.getResult());
log.info("resultReceived ServiceMethod Name
"+call.getServiceMethodName());
}
catch (Exception err) {
log.error("resultReceived",err);
}
}
Hope this helps. A good start would be to check out the example war.
-Anthony Bargnesi
On Wed, Mar 12, 2008 at 10:09 AM, Tobias Wolf <[EMAIL PROTECTED]>
wrote:
> Hi all,
>
> i just want to know if this is possible.
>
> What i want to accomplish is an application that gets updated from the
> server without the need to poll every second, but it should connect
> itself and when wait for new data. Once the server has send new data a
> ondata function gets called, or better, a dataset gets updated and the
> application can show the new data.
>
> Is this possible with OpenLaszlo and Red5 ?
>
> The only other chance for doing something like this is the Flash
> XMLSocket, but since i already want to use the Red5 Server for media
> streaming i thought, maybe he can do both and i don't have to deal with
> two different instances for managing data.
>
> Thx in advance,
>
> --
>
> Tobias Wolf
>
>
>
>