[Red5] Object scope not scoped right...

Jake Hilton red5 at jakehilton.com
Tue Jan 13 12:27:45 PST 2009


I figured out what the problem was.. amongst MUCH debugging and trial and
error.

If you do a .get on a HashMap to a property that doesn't exist the script
stops executing at that point. I just created my instance property in the
usersObj in the roomStart method because that's called only when the scope
starts up initially.

I hope this helps someone if they come to the same problem.

Thanks for your help Tyler!

Jake

On Tue, Jan 13, 2009 at 10:38 AM, Jake Hilton <red5 at jakehilton.com> wrote:

> I think I'm getting closer.. so:
>
> public boolean appStart(IScope app) {
>         userObj = new HashMap<IScope,
> HashMap<String,HashMap<String,String>>>();
>         userObj.put(app,new HashMap<String,HashMap<String,String>>());
>
>
> Seems to work fine.. as far as I can tell. But I have another problem now:
>
> public boolean appConnect(IConnection conn, Object[] params) {
>
>         HashMap auth_obj = (HashMap)params[0];
>
>             String curr_uid = auth_obj.get("uid").toString();
>             String curr_uname = auth_obj.get("uname").toString();
>
>             conn.setAttribute("uid", curr_uid);
>
>             HashMap<String,String> curr_user_info = new
> HashMap<String,String>();
>             curr_user_info.put("label", curr_uname);
>             curr_user_info.put("data", curr_uid);
>
>             ServiceUtils.invokeOnAllConnections("clientConnected", new
> Object[]{curr_user_info});
>
>             HashMap<String,HashMap<String,String>> instance_users =
> userObj.get(conn.getScope());
>             instance_users.put(curr_uid, curr_user_info);
>
>
> The above causes the infamous: WARN  o.r.server.net.rtmp.RTMPConnection -
> Closing RTMPMinaConnection from xxx.xx.xx.xx : 51394 to xx.xxx.xxx.232 (in:
> 3522 out 3221 ), with id 16491778 due to long handshake
>
>
> Any blaring issues around this?
>
> Thanks,
> Jake
>
>
>
> On Tue, Jan 13, 2009 at 9:25 AM, Jake Hilton <red5 at jakehilton.com> wrote:
>
>> Thanks for the postback Tyler.
>>
>> So would you recommend instantiating that in the Application class
>> constructor or do a check for existance in the appConnect method and create
>> it there?
>>
>> Thanks,
>> Jake
>>
>>
>> On Mon, Jan 12, 2009 at 4:25 PM, Tyler Kocheran <rfkrocktk at gmail.com>wrote:
>>
>>> appConnect is fired whenever a client connects to any scope on the
>>> current application. Remember that the same ApplicationAdapter is supplied
>>> to all connecting clients on that webapp. If you're storing this in a
>>> instance variable, that might not be wise, because every client will get
>>> inserted to that, no matter what subscope they belong to. If you really want
>>> to store this in an instance variable, I'd suggest a variable like this:
>>> Map<IScope, List<IClient>>. That variable will allow each scope to have its
>>> own client list, separately.
>>>
>>> On Mon, Jan 12, 2009 at 3:08 PM, Jake Hilton <red5 at jakehilton.com>wrote:
>>>
>>>> I deleted one too many lines from my appConnect method..  :)  Here is
>>>> what it really looks like:
>>>>
>>>> public boolean appConnect(IConnection conn, Object[] params) {
>>>> //auth_key, user_id, user_name
>>>>
>>>>             HashMap auth_obj = (HashMap)params[0];
>>>>
>>>>             HashMap<String,String> curr_user_info = new
>>>> HashMap<String,String>();
>>>>             curr_user_info.put("label",
>>>> auth_obj.get("uname").toString());
>>>>             curr_user_info.put("data", auth_obj.get("uid").toString());
>>>>
>>>>             userObj.put(auth_obj.get("uid").toString(), curr_user_info);
>>>>
>>>>         return true;
>>>>     }
>>>>
>>>> I've tried to get it working on 0.8 rc1 and the trunk as of today.. and
>>>> no dice.
>>>>
>>>> Thanks,
>>>> Jake
>>>>
>>>>
>>>>
>>>> On Mon, Jan 12, 2009 at 4:04 PM, Jake Hilton <red5 at jakehilton.com>wrote:
>>>>
>>>>> Hey all.
>>>>>
>>>>> Just doing some somewhat boiler plate stuff.. but I'm not getting the
>>>>> results I thought I should.. I am creating an object when the application
>>>>> starts up. I update that object as clients connect and disconnect.
>>>>>
>>>>> When a client connects he requests that object so as to list the total
>>>>> number of clients and their details connected to that instance... the
>>>>> problem is the object contains all the users connected across all the
>>>>> instances of that application. I'm sure it's a simple scope issue but I
>>>>> can't figure it out. Code below:
>>>>>
>>>>> #########
>>>>>
>>>>> //Application file
>>>>>
>>>>> public boolean appStart(IScope app) {
>>>>>         userObj = new HashMap<String,HashMap<String,String>>();
>>>>>
>>>>>         log.debug("> App ready");
>>>>>         return true;
>>>>>     }
>>>>>
>>>>> public boolean appConnect(IConnection conn, Object[] params) {
>>>>> //auth_key, user_id, user_name
>>>>>
>>>>>             HashMap<String,String> curr_user_info = new
>>>>> HashMap<String,String>();
>>>>>             curr_user_info.put("label",
>>>>> auth_obj.get("uname").toString());
>>>>>             curr_user_info.put("data", auth_obj.get("uid").toString());
>>>>>
>>>>>             userObj.put(auth_obj.get("uid").toString(),
>>>>> curr_user_info);
>>>>>
>>>>>         return true;
>>>>>     }
>>>>>
>>>>> //Service file
>>>>> public HashMap<String,HashMap<String,String>> getUserList()
>>>>>     {
>>>>>
>>>>>         IScope scope = Red5.getConnectionLocal().getScope();
>>>>>         Application app = (Application)scope.getHandler();
>>>>>
>>>>>         return app.userObj;
>>>>>     }
>>>>>
>>>>> #########
>>>>>
>>>>> Any help would be much appreciated.
>>>>>
>>>>> Jake
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Red5 mailing list
>>>> Red5 at osflash.org
>>>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>>>
>>>>
>>>
>>>
>>> --
>>> And do this, knowing the time, that now it is high time to awake out of
>>> sleep;
>>> for now our salvation is nearer than when we first believed.
>>>
>>> _______________________________________________
>>> Red5 mailing list
>>> Red5 at osflash.org
>>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://osflash.org/pipermail/red5_osflash.org/attachments/20090113/f39b0d44/attachment-0001.html>


More information about the Red5 mailing list