disconnect() calls a sysDisconnectEvent of it's own

Bug #1676955 reported by Roland Goldberg
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mudlet
Opinion
Undecided
Unassigned

Bug Description

Sample Code:

function doubleEcho()
  cecho("\n<black:yellow>This will echo twice, but only if currently connected to the MUD when disconenct() is called")
end

registerAnonymousEventHandler("sysDisconnectionEvent","doubleEcho")

disconnect()

Explanation:

sysDisconnectEvent is designed to let you know that the connection to the MUD has been terminated. However, regardless of whether there is a connection to the MUD, calling the disconnect() function raises sysDisconnectEvent. When connected to a MUD, this results in sysDisconnectEvent being called twice if you manually run a disconnect(). If the MUD disconnects you on the other hand, you only get one sysDisconnectEvent, as proper.

Usually this is no problem. However, sometimes a function that is registered to sysDisconnectEvent will have issues if it is run twice. Other times you may not want said function to run unless already connected to the MUD when disconnect() is called.

Revision history for this message
Stephen Lyons (slysven) wrote :

IIRC we do not currently track the connection status properly - (there are unused variables associated with connection time-out and retries) - but I think it is something that does need to be done (for instance running a "replay" only really makes sense when "off-line" IMHO). Tracking such status details (and optionally providing that information to user or their scripts) would provide the information to properly handle the situation here, either internally or to allow scripts to handle it...

Revision history for this message
Roland Goldberg (phoenixcodes) wrote :

While I'm all for the above variables for tracking connection or non-connection, this is doable via sysConnectionEvent and sysDisconnectEvent by the user if they are properly implemented.

Granted, I'm not familiar with the backend code on disconnection. However, as I get a sysDisconnectEvent from Mudlet when the MUD initiates disconnect, I assume that Mudlet has some method of determining when the change from connected to disconnected happens. I propose that this be the only time that sysDisconnectEvent is raised - not when someone calls disconnect(), which is just the command to Mudlet 'hey, go disconnect', which won't do anything if the MUD isn't already connected - can't terminate a non-open connection, eh?

Revision history for this message
Roland Goldberg (phoenixcodes) wrote :

Per above, I believe that commenting line 189 of ctelnet.cpp would accomplish this; the duplication comes when cTelnet::disconnect() raises the event, and then cTelnet::handle_socket_signal_disconnected() calls the event when the socket is actually disconnected. If I'm interpreting the code right.

Revision history for this message
Vadim Peretokin (vperetokin) wrote :

Migrating issues to Github, please follow the new discussion here:
https://github.com/Mudlet/Mudlet/issues/778

This issue needs to be closed and there is no appropriate status, so
will set it to "Opinion" just for migration purposes.

Changed in mudlet:
status: New → Opinion
Revision history for this message
Vadim Peretokin (vperetokin) wrote :

Migrating issues to Github, please follow the new discussion here:
https://github.com/Mudlet/Mudlet/issues/821

This issue needs to be closed and there is no appropriate status, so
will set it to "Opinion" just for migration purposes.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.