[Red5] SO doesnt recieve onsync events on refresh when only client
Trevor Burton
worldofpaper at googlemail.com
Tue Apr 8 23:55:58 PDT 2008
I had the same problem.
If you have two connected clients and refresh one of them, i'm guessing
things will be fine. It's when you only have one connected client and
refresh that, so there are no clients connected to the Shared Object.
I fixed it by adding a check in the disconnect() method of the
ApplicationAdaptor - if there are no clients connected i call
SharedObject.close(). then when another client joins i recreate the Shared
Object.
Another fix might be to have a listener on the server-side, so that there's
always at least one client listening.
hth
t
On Wed, Apr 9, 2008 at 12:18 AM, <dmcardle at satx.rr.com> wrote:
> Hello all,
>
> I have a SharedObject issue. I am sure I just don't understand some basic
> principal. I don't know if it is on my client or server. If I have a
> single
> client connected and listening on a shared oject for a chat, it works
> fine. I
> created a test app with a single button that invokes a call on the net
> connection like so, nc.call("sendMessage", new Responder(call1_result,
> call1_fault), message);. On the ApplicationAdapter, I update the chat
> shared
> object. The client recieves the onSync event without problems. On app
> start I
> did the following:
>
> @Override
> public boolean appStart(IScope app) {
> if (super.appStart(app)) {
> Boolean create = createSharedObject(scope, "Chat", false);
> if (!create)
> return false;
> chatSO = getSharedObject(scope, "Chat");
> chatSO.addSharedObjectListener(new AppSharedObjectListener());
> chatSO.acquire();
> return true;
> } else {
> return false;
> }
> }
>
> I expected that would keep the shared object around until the apps stops.
>
> @Override
> public void appStop(IScope app) {
> chatSO.release();
> super.appStop(app);
> }
>
> It appears to work. But when I refresh my client, the client stops
> receiving
> the onSync events. I included my SOTest.mxml which is a simple client
> that
> connects and displays the events. I also included my
> TestApplicationAdapter
> which creates my serverside shared object. I need to be able to refresh
> the
> client when it is the only client connected and still keep receiving the
> onSync
> events. Any help would be greatly appreciated. -David
>
>
> package com.franklincovey.webinar;
>
> import java.util.ArrayList;
> import java.util.List;
> import java.util.Map;
>
> import org.red5.server.adapter.ApplicationAdapter;
> import org.red5.server.api.IScope;
> import org.red5.server.api.Red5;
> import org.red5.server.api.so.ISharedObject;
>
> import com.franklincovey.webinar.client.model.vo.MessageVO;
> import com.franklincovey.webinar.client.service.SharedObjectAttribute;
>
> public class TestApplication extends ApplicationAdapter {
> private ISharedObject chatSO;
>
> @Override
> public boolean appStart(IScope app) {
>
> if (super.appStart(app)) {
>
> Boolean create = createSharedObject(scope, "Chat",
> false);
>
> if (!create)
> return false;
>
> chatSO = getSharedObject(scope, "Chat");
> chatSO.addSharedObjectListener(new
> AppSharedObjectListener());
> chatSO.acquire();
>
> return true;
> } else {
> return false;
> }
>
> }
>
> @Override
> public void appStop(IScope app) {
> chatSO.release();
> super.appStop(app);
> }
>
> public void sendMessage(MessageVO message){
> Map<String, Object> soAttributes = chatSO.getAttributes();
> if(soAttributes == null || soAttributes.get("message") ==
> null){
> message.setIndex(0);
> } else {
> message.setIndex(((MessageVO)
> soAttributes.get("message")).getIndex() + 1);
> }
> Long time = new Long(System.currentTimeMillis());
> message.setTime(time.longValue());
> chatSO.setAttribute("message", message);
> }
> }
>
>
> _______________________________________________
> Red5 mailing list
> Red5 at osflash.org
> http://osflash.org/mailman/listinfo/red5_osflash.org
>
>
--
Trevor Burton
http://www.paperworld3d.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/red5_osflash.org/attachments/20080409/76f842d7/attachment-0001.html
More information about the Red5
mailing list