SPADS
SPADS copied to clipboard
Update example code snippet provided in the Wiki, and corresponding example plugins
(I am unable to submit a PR for the Wiki, hence this issue)
This page:
- https://github.com/Yaribz/SPADS/wiki/SPADS-plugin-development-(Python)#user-content-Writing_plugin_code-2
... contains the following:
However, if SPADS is disconnected from the lobby due to network problems for example, all lobby handlers are automatically removed. So we must re-add them each time we connect to lobby server. This can be done using the [http://planetspads.free.fr/spads/doc/spadsPluginApiDoc.html#onLobbyConnected-self-lobbyInterface onLobbyConnected] event-based callback as follows:
# This callback is called each time we (re)connect to the lobby server def onLobbyConnected(self,lobbyInterface): # When we are disconnected from the lobby server, all lobby command # handlers are automatically removed, so we (re)set up our command # handler here. spads.addLobbyCommandHandler({'SAIDBATTLE': hLobbySaidBattle})
However, based on advice provided by Yaribz, some commands may be missed if handlers are registered in onLobbyConnected(...)
instead of onLobbyLogin(...)
. So, I believe this page should be updated to switch which callback is used.
Similarly, the example plugins which use onLobbyConnected(...)
should probably be updated as well:
- https://github.com/Yaribz/SPADS/blob/c11f4cc31b12ab98ae6ba8b90f19f85247346e70/plugins/tutorials/forbiddenwords.py#L55
- https://github.com/Yaribz/SPADS/blob/c11f4cc31b12ab98ae6ba8b90f19f85247346e70/plugins/tutorials/ForbiddenWords.pm#L58