Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Suggestions ➜ OnWorldTimeOut (Automatically called)

OnWorldTimeOut (Automatically called)

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Magnum   Canada  (580 posts)  Bio
Date Sat 28 Sep 2002 08:46 AM (UTC)

Amended on Sat 28 Sep 2002 09:00 AM (UTC) by Magnum

Message
I would like to suggest that MUSHclient automatically calls a subroutine, perhaps named "OnWorldTimeOut" (or "OnWorldConnectionTimeOut" - longer, but more accurate) in the World script file, and any of it's plugin script files.

This would eliminate the need for a timer and script pair to 'manually' check the connection status periodically. Small overhead, but all overhead counts when efficiency is a concern.

This would also allow for 'reconnect' scripts that only make re-attempts the one time they should, when a connection times out. (It's not likely you want your reconnect script to reconnect you when you purposely logged off, etc).

I suspect this would be a simple modification to MUSHclient, since you already call "OnWorldDisconnect", and several other 'automated' subroutine calls, and since you present a 'connection timed out' window (if configured). Nick, I imagine you would just add a single programming line (right near where you present that window). That's assuming you call an internal subroutine which in turn makes the 'automated' script calls, if the subroutine exists. If not, it's still just copy and paste of the MUSHclient source code that calls "OnWorldDisconnect", with minor editing. :)

I checked the sample file to make sure this routine doesn't already exist. Also checked the help for function "Connect" and "Disconnect" (where you should note this automated subroutine, if you add it). I also reviewed the release notes for version 3.19, where some related changes were made.

Man, I tend to babble...

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 28 Sep 2002 10:13 AM (UTC)
Message
How do you know you timed out? A disconnect not preceded by a quit? How about just putting in a "quit" alias, which sets a flag. You then test that flag in OnDisconnect. Clear the flag in OnConnect.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #2 on Sat 28 Sep 2002 07:29 PM (UTC)

Amended on Sat 28 Sep 2002 11:45 PM (UTC) by Nick Gammon

Message

FILE | GENERAL PREFERENCES | GENERAL | Notify me if unable to connect


By far, the most frequent error you will recieve when that option is turned on, is error 10060 (Connection Timed Out).


Now, in my opinion this is by far the most common time someone will want to re-attempt a connection. (Perhaps on failed DNS lookup, if your nameserver is down, and you are waiting for it to go back up - RARE).

Now, currently, your suggestion is to:

Make a subroutine to set a flag when connected.
Make a subroutine to set a flag when disconnected appropriately.
Make a timer to call a script.
Have the script called by the timer check the state of the flag and the connection status, 
and make a re-attempt if appropriate.


Here are a couple of downsides to that:

  • COM calls to script file. Everytime you call your script file, there is a very minor lag during this process.
  • Since you don't know when you are disconnected, you must make periodic checks to see if you are connected. From previous point, this translated to periodic lag suffering.
  • Since you don't know when you are disconnected, it would be very hard to time your script to make an attempt immediately when the connection fails. Instead, you have to wait until the next time the timer checks your connection status. You could set the timer to be the same as the 'Connection Time Out' grace period, but see second point, above.

Some thoughts...

  • I don't know if "OnWorldDisconnect" is called when the connection attempt times out (above). I doubt it.
  • If "OnWorldDisconnect" is called, there is no means that I know of to check the error code (reason) for the disconnection. (No argument is passed).

Now, I know the lag times I am talking about are so minute they may seem insignificant, but when you have a huge world file with several plugins, efficiency becomes a concern. Inefficient code adds up, and the cummulative effect can be significant. So, it's wise to be as efficient as possible wherever one can. :)

It seems natural that the user would want to make a reconnection attempt immediately, when presented with the error window above (Connection Timed Out). Or, if they want to be polite about it, start a timer to make a re-attempt later, starting from the time that message is presented.

There's the rub. There is no automated way to run script when that error window is presented, and that's my submission, that you automatically call a certain subroutine, if it exists, in the root world file, or in any of it's plugins. To be more flexible, you might change it to something like this:

OnWorldConnectionError(ErrorCode)
OnPluginConnectionError(ErrorCode)


...and then, in my case, I would check to see if the argument was code 10060.

As I said earlier, I thought it would probably be relatively simple for you to add this feature, by simply making the call immediately prior or following your source code that presents that window above. :)

I feel this would be far more efficient than the method you recommend.

(For other people reading: There is already an option to "Reconnect on Disconnect", but the automated procedure will not function if there was a connection error).

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #3 on Sat 28 Sep 2002 11:53 PM (UTC)
Message
OK, let's explore this a bit more.

Are you referring to - and I think you are - being unable to connect in the first place? Connection timed out suggests the MUD is down.

A while ago I added the "active when disconnected" option to timers, so you can run a timer while the world is not connected.

What is wrong with this? - he asks, hoping for the answer "nothing"...

  1. Make a plugin that, when installed, activates a "connection test" timer
  2. The connection test timer (say, every 10 seconds), checks to see if the world is connected, and if not, does a connect, perhaps with a world.note to notify you.
  3. Once the world is connected, the "onconnect" disables the timer, so that you do not waste any CPU cycles during normal processing
  4. The "ondisconnect" re-enables the timer, unless preceded by a "quit" command (by having quit call an alias that sets a flag).
  5. To reconnect after a deliberate quit, you might need to call a script from the command window, eg.

    /connect_me

    This would re-enable the timer, and fire off the first connect attempt.


I can do an example plugin if you like, but I imagine you could too. The only thing this doesn't do is test the reason for disconnection, which perhaps isn't too important.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #4 on Sun 29 Sep 2002 04:49 AM (UTC)
Message
Heh, Nick... I can't help but feel you didn't really read my last post. Probably 'skimmed' over it. LOL. I said there why I don't think your method is very efficient.

The attempt to connect could be both: An initial attempt to connect after loading the client, or an attempt to re-connect after losing a connection.

Most likely a connection time out will mean the mud is down, but it could also be a key server along the route is down (Something more common with AgesOfDespair's host).

In my case, I am exploring the issue right now because the mud has been down for a couple of days straight, so currently, yes, I am trying to make an initial connection...

...and I just paid more attention, and realized that the plugins do not initialize until a connection is made. That kind of screws up the plan to use a plugin to try the connection attempts. :(

I was planning to write a plugin to automatically attempt to connect, repeatedly, but only when there was a connection error. Otherwise, MUSHclient already has sufficient tools for connecting on open, or on unexpected disconnect.

Anyway, you are obviously resistant to this idea. That's cool. I think I'll just do without any automated attempt to reconnect for now. It's really not that big of an issue, normally... It's rare that my mud has been down for so long, so it's only twice a year or so that I would use such a plugin anyway.

AOD is a mud where you must store EQ over reboots, or lose it. If a server goes down in mid-play, you may feel an urgent need to re-connect just to store your EQ. (I'm ok this time, my EQ was stored before mud went silent). :)

Man, babbling once more. No wonder you 'skim'! LOL.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #5 on Mon 30 Sep 2002 10:27 AM (UTC)
Message
Quote:

plugins do not initialize until a connection is made


No, that is not true. My example below demonstrates that.

Quote:

Anyway, you are obviously resistant to this idea. That's cool. I think I'll just do without any automated attempt to reconnect for now.


Only because it can be done today in a plugin. I have written one to demonstrate the idea, but put it in the plugins section of the forum, see below.

If you turn off "automatic connect" but load a world with this plugin installed, it will attempt to connect you, and if you drop the connection (eg. using the Connection menu -> Disconnect) immediately try to reconnect you (or at least, after the time interval for the timer expires).

See this post ...


http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=1802

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #6 on Mon 30 Sep 2002 06:11 PM (UTC)
Message
Yes, I never doubted your method would work.
Quote:

<timers>
  <timer name="ConnectCheckTimer"        script="OnConnectCheckTimer" 
       second="&interval;" active_closed="y" enabled="y">
  </timer>
</timers>

I just don't want that timer firing, making a COM call every 10 seconds, unless I really need it. ...So, I would only ebable your plugin on demand, when I really needed it, then disable it the rest of the time.

If you had adopted my idea, the worries about reconnecting when you don't want to would not be an issue, nor would the resource consumption of running script every 10 seconds be an issue... but I don't want to get argumentitive about this. Your plugin does do the job sufficiently. Thanks. :)

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #7 on Mon 30 Sep 2002 08:37 PM (UTC)
Message
Yes, I understand that point, which is why the OnPluginConnect sub *disables* the timer as soon as the world is connected.

Thus while the world is connected (presumably the bulk of the time) then the timer is disabled, and no COM or other resources are consumed, excepting the very minor time taken for MUSHclient to skip an inactive timer in its timer list.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #8 on Tue 01 Oct 2002 04:04 AM (UTC)
Message
Ah, Ok. Smart! :)

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


23,675 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.