Hi,
I created a room with some extension Logic using SFS2X and i added below setting at the time of room creation
settings.setAutoRemoveMode(SFSRoomRemoveMode.WHEN_EMPTY);
In the event Handler i added below Events for the Room based Logic
addEventHandler(SFSEventType.USER_DISCONNECT, eventHandler.class);
addEventHandler(SFSEventType.USER_LEAVE_ROOM, eventHandler.class);
addEventHandler(SFSEventType.USER_JOIN_ROOM,eventHandler.class);
At the time of a single user will comes out of the room, Room Need to be deleted automatically but Room Leave event and room disconnect event will be capture in the Room Extension
I attach my error screen shot in this mail, Please go through the screen shot
Room Instance Not deleted after delete executed
-
- Posts: 108
- Joined: 06 Jan 2010, 09:50
- Location: chennai
- Contact:
Room Instance Not deleted after delete executed
- Attachments
-
- Error.jpg
- (160.52 KiB) Not downloaded yet
Sankar.G
Re: Room Instance Not deleted after delete executed
Hi,
from the error in the stack trace it is not very clear what is going on, and what Event is being handled by your code. Maybe you can clarify which even are we looking at in that stack trace.
Side Note: if you're using the same handler for the three different events (JOIN, LEAVE, DISCONNECT) I am not sure how you can differentiate which event you're dealing with.
It would be much better to create separate event handlers.
From the error in the stack trace it seems like you're handling a USER_DISCONNECT event and your code is trying to send some data to the disconnected user which, of course, is not possible because the user is already gone. Hence the socket write error.
Hope it helps
from the error in the stack trace it is not very clear what is going on, and what Event is being handled by your code. Maybe you can clarify which even are we looking at in that stack trace.
Side Note: if you're using the same handler for the three different events (JOIN, LEAVE, DISCONNECT) I am not sure how you can differentiate which event you're dealing with.
It would be much better to create separate event handlers.
From the error in the stack trace it seems like you're handling a USER_DISCONNECT event and your code is trying to send some data to the disconnected user which, of course, is not possible because the user is already gone. Hence the socket write error.
Hope it helps
-
- Posts: 108
- Joined: 06 Jan 2010, 09:50
- Location: chennai
- Contact:
Re: Room Instance Not deleted after delete executed
Not only this problem ...If i create any timers in the room Extension after user will comes out Room
Room need to be deleted but timer created in the room is keep on running
I shows logs in why it is so ?
I am handling all 3 events in single class using if condition i separate this
if(event.getType().equals(SFSEventType.USER_DISCONNECT))
Room need to be deleted but timer created in the room is keep on running
I shows logs in why it is so ?
I am handling all 3 events in single class using if condition i separate this
if(event.getType().equals(SFSEventType.USER_DISCONNECT))
Sankar.G
Re: Room Instance Not deleted after delete executed
In my previous post I have suggested what is the nature of the problem: you're attempting to send data to a disconnected user.
Can you please come back to me on this point?
Is this correct? If so, please modify your code.
Because scheduled tasks need to be terminated manually when it's necessary.
In your case you must call the cancel() method on your task in the destroy() method of your Room Extension.
See more details here:
http://smartfoxserver.com/blog/how-to-s ... extension/
Hope it helps
Can you please come back to me on this point?
Is this correct? If so, please modify your code.
Room need to be deleted but timer created in the room is keep on running
I shows logs in why it is so ?
Because scheduled tasks need to be terminated manually when it's necessary.
In your case you must call the cancel() method on your task in the destroy() method of your Room Extension.
See more details here:
http://smartfoxserver.com/blog/how-to-s ... extension/
Hope it helps
-
- Posts: 108
- Joined: 06 Jan 2010, 09:50
- Location: chennai
- Contact:
Re: Room Instance Not deleted after delete executed
Yes you correct !!!
i stored sfs users in arraylist and i will remove the user at the time of user disconnect from the array but it array size is not reduced with in fraction of seconds that why may be problem raised and if user disconnected i need to send msg to other users in the game play for user disconnected user
And if room is deleted how i will cancel the schedule task running in the specified room ?
i stored sfs users in arraylist and i will remove the user at the time of user disconnect from the array but it array size is not reduced with in fraction of seconds that why may be problem raised and if user disconnected i need to send msg to other users in the game play for user disconnected user
And if room is deleted how i will cancel the schedule task running in the specified room ?
Sankar.G
Re: Room Instance Not deleted after delete executed
sankarganesh86 wrote:And if room is deleted how i will cancel the schedule task running in the specified room ?
As I explained in my previous reply.
You must override the destroy() method:
Code: Select all
@Override
public void destroy()
{
super.destroy();
if (myTask != null)
myTask.cancel();
}
When the Room is removed the Extension's destroy() method is invoked.
For more, again, see the link in my previous reply.
Cheers
-
- Posts: 108
- Joined: 06 Jan 2010, 09:50
- Location: chennai
- Contact:
Re: Room Instance Not deleted after delete executed
I created task scheduler not in base class and that task scheduler class in not the extension of the SFSEXTENSION
It is separate class then how we will destroy from the base class using below function in the base class ?
@Override
public void destroy()
{
super.destroy();
if (taskHandle != null)
taskHandle.cancel();
}
It is separate class then how we will destroy from the base class using below function in the base class ?
@Override
public void destroy()
{
super.destroy();
if (taskHandle != null)
taskHandle.cancel();
}
Sankar.G
Re: Room Instance Not deleted after delete executed
You just need to destroy the task, not the Scheduler... unless the Scheduler was also created in the Room Extension. But I would not recommend that as you end up creating too many Schedulers which is bad for performance.
So, when you create the task keep a reference to it (as per the documentation I've already linked) and in the destroy method you can cancel it.
Cheers
So, when you create the task keep a reference to it (as per the documentation I've already linked) and in the destroy method you can cancel it.
Cheers
-
- Posts: 108
- Joined: 06 Jan 2010, 09:50
- Location: chennai
- Contact:
Re: Room Instance Not deleted after delete executed
Thanks Lapo,
And error in stack in the eventHandler class
Before sending data to the user i will check if the user is connected or not
User.isConnected() status and i will send the data
it will clear that problem ?
And error in stack in the eventHandler class
Before sending data to the user i will check if the user is connected or not
User.isConnected() status and i will send the data
it will clear that problem ?
Sankar.G
Re: Room Instance Not deleted after delete executed
I don't think you need to do that. All you need is not sending data in the USER_DISCONNECT event, as I explained.
-
- Posts: 108
- Joined: 06 Jan 2010, 09:50
- Location: chennai
- Contact:
Re: Room Instance Not deleted after delete executed
ok Thanks Lapo!!!
I will update the code
I will update the code
Sankar.G
-
- Posts: 108
- Joined: 06 Jan 2010, 09:50
- Location: chennai
- Contact:
Re: Room Instance Not deleted after delete executed
As per you suggestion i override the destory function and wrote cancel all timers in the code
but it still running after room deleted
Please see get the attachment !!!
In the destory method i put some traces too but that is also not coming in the logs
but it still running after room deleted
Please see get the attachment !!!
In the destory method i put some traces too but that is also not coming in the logs
- Attachments
-
- Error.png
- (61.24 KiB) Not downloaded yet
Sankar.G
Re: Room Instance Not deleted after delete executed
So you're using Timers (java.util.Timer) not the SmartFox Scheduler...
This wasn't very clear from your question.
In any case we don't recommend using Java Timers, they are an old system from Java 1.3 that has been replaced by more efficient Task Schedulers. The main problem with timers is that each instance is backed by a dedicated Thread which causes poor performance if you plan to use hundreds of them.
I would highly recommend to use the system described in the article I've already linked before:
http://smartfoxserver.com/blog/how-to-s ... extension/
With this said if you're only using a few Timers you can keep them. As regards your specific issue though I have no idea as I don't know what your code does. What I can say is that there's certainly an error somewhere that prevents the proper disposal of those Timers.
Best thing to do is debugging each issue one by one.
Thanks
This wasn't very clear from your question.
In any case we don't recommend using Java Timers, they are an old system from Java 1.3 that has been replaced by more efficient Task Schedulers. The main problem with timers is that each instance is backed by a dedicated Thread which causes poor performance if you plan to use hundreds of them.
I would highly recommend to use the system described in the article I've already linked before:
http://smartfoxserver.com/blog/how-to-s ... extension/
With this said if you're only using a few Timers you can keep them. As regards your specific issue though I have no idea as I don't know what your code does. What I can say is that there's certainly an error somewhere that prevents the proper disposal of those Timers.
Best thing to do is debugging each issue one by one.
Thanks
Who is online
Users browsing this forum: No registered users and 46 guests