Problem with native actionscript Array

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Post Reply
Kleon
Posts: 37
Joined: 19 Mar 2010, 07:03

Problem with native actionscript Array

Post by Kleon »

Hello,

I use actionscript to develop my server side extension and use Array[] to collect users in special sequence.
How I use the array:
After some actions I delete an user from the array and add it again to the end of the array in a some time.

The problem:
When the server do it for 2000 users for a 10-20 minutes, then it is crashed. I have removed actions with the array from my code and it has started to work ok.

Note1: was deleted actions to add, delete and get users from the array. Business logic didn't changed. (to provided access to users I used room.getAllUsers() instead of the array)
Note2: I traced the array length, it is never be more than total users amount from Admin panel.
Note3: It seems errors appear when test NPC users start to disconnect by timeout.

Here is the cut from Smartfox wrapper. (I don't think that it can help, because there are many other errors appear too):

Code: Select all

       
at org.mozilla.javascript.JavaAdapter.access$000(JavaAdapter.java:53)
        at org.mozilla.javascript.JavaAdapter$1.run(JavaAdapter.java:517)
        at org.mozilla.javascript.Context.call(Context.java:577)
        at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:503)
        at org.mozilla.javascript.JavaAdapter.callMethod(JavaAdapter.java:514)
        at adapter1.doTask(<adapter>)
        at it.gotoandplay.smartfoxserver.util.scheduling.Scheduler.executeTasks(
Scheduler.java:314)
        at it.gotoandplay.smartfoxserver.util.scheduling.Scheduler.run(Scheduler
.java:223)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
        at java.lang.Thread.run(Thread.java:619)
13:24:13.498 - [ FINE ] > Removed NPC connection: java.nio.channels.SocketChanne
l[closed]
13:24:13.498 - [ FINE ] > User [ 6168 ] removed
13:24:13.499 - [ WARNING ] > Error in extension [ chatApplicationExtensions/main
Extension_vk.as ]: TypeError: Cannot call method "getName" of undefined (chatApp
licationExtensions/mainExtension_vk.as#3488) Internal: 1911 -- Line number: 1910
 in file: chatApplicationExtensions/mainExtension_vk.as
13:24:13.500 - [ FINE ] > Removed NPC connection: 
Why this problem may appear? Can I use Collections instead of the array in my as1 extension?
And additional question. Is it possible to lost an user without userLost event firing in extension?

Thanks.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

This is very difficult to say without knowing what your code does.
You could use Java collections instead of Arrays if you wish. If you do so make sure that you always use thread safe collections because Actionscript has no way of locking/synchronizing unsafe collections.

How to use Java classes in Actionscript is explained here:
http://smartfoxserver.com/docs/docPages ... script.htm
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply