About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
intoK
Apprentice


Joined: 18 Feb 2007
Posts: 190

PostPosted: Fri Jan 08, 2010 4:45 pm   

[3.12] onexit event
 
never raises
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Jan 08, 2010 5:45 pm   
 
It does, but it depends upon how you are exiting. It normally fires when a window is closed. Here is a test that shows it working:

1) Create another window: #WINDOW Test
2) right-click on the Test window and turn on the Command Line
3) In the Command Line for the Test window, enter:

#EVENT onExit {#WINDOW untitled "test window closed"}

4) test this using: #RAISE onExit
5) Now close the Test window clicking the X in the upper-right corner of the window. You'll see the message displayed in the main window.

When you exit CMUD completely or close a main session window, the MUD connection has already been closed before onExit fires. So your onExit event cannot send anything to the MUD. And depending upon how you close an application (File/Quit vs clicking the red X button in the corner), Windows sends different messages to the application. So I will need to know exactly what you are doing in your onExit event and exactly how you are closing CMUD.
Reply with quote
intoK
Apprentice


Joined: 18 Feb 2007
Posts: 190

PostPosted: Fri Jan 08, 2010 10:55 pm   
 
cheers!
i dont intend on sending anything, just trying to save some lua tables, dumping them to db takes good 100ms so i dont want this on timer or in too many places...
im closing either by window close button or alt+f4
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Jan 13, 2010 10:37 pm   
 
Hmm, I'm not sure if Lua is available in the OnExit event. At the time of OnExit, I think the COM interfaces (like for Lua) have already been closed. It's not a good idea to put anything in OnExit that takes very much time. This is also the event that fires when Windows wants to shutdown and CMUD is running, and Windows will complain if a program takes too long to shut down. Not sure where else to put this kind of stuff, but maybe in the OnDisconnect event?
Reply with quote
intoK
Apprentice


Joined: 18 Feb 2007
Posts: 190

PostPosted: Fri Jan 15, 2010 8:56 pm   
 
cheers
naw, ondisconnect dosnt fire when closing either, for now i just stuck some save calls in crucial places

but imo, onexit should be exactly for that, some cleanup code when cmud exits, afair windows waits for the process for predefined time, (2-3s?) before either asking to kill it or killing it automatically depending on registry settings
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Jan 15, 2010 10:18 pm   
 
No, it's very bad practice to try and force an application to delay when Windows wants to close it. Causes problems when trying to shut down Windows when the application is running. I'll take a look at it when I can. But it sounds like something else is wrong since I'm sure the onDisconnect event is firing when Windows disconnects the network socket.
Reply with quote
intoK
Apprentice


Joined: 18 Feb 2007
Posts: 190

PostPosted: Sun Jan 17, 2010 12:52 pm   
 
well, nothing was saved when i tried them procs there, also nothing gets printed to any window, nor zs.beep produces a sound, so either it dosnt fire or lua is already closed
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Jan 18, 2010 6:46 pm   
 
Printing to the window isn't going to work in onExit because the window is getting closed. But it should work in onDisconnect. In fact, I just tried it:

#EVENT onDisconnect {#say Disconnecting}

and then did:

#DIS

to disconnect my session, and it properly displayed "Disconnecting". So there must be something else going on in your session.
Reply with quote
intoK
Apprentice


Joined: 18 Feb 2007
Posts: 190

PostPosted: Mon Jan 18, 2010 10:48 pm   
 
umm, what i was saying is that ondisconnect dosnt fire when exiting (as you suggested in previous posts), it sure works fine when actually disconnecting without closing cmud

anyhow, i put all 3 table updates in one big begin/commit block and it now takes 70ms tops, not ideal but bearable Smile
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Tue Jan 19, 2010 12:01 am   
 
Well, this is back to the original problem then. As I think I said at the beginning, when you exit an application, it doesn't necessarily get the same set of Windows messages or any chance to respond to them before the application exits.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net