View Full Version : When A Client Connects ...
UrsaTeddy
July 5th, 2021, 12:21
Greetings,
I have an extension that gives the GM a few options to turn on/off for their game.
When this is done, an OOB message is sent to the client to perform some actions to enable these items.
So far it works as intended, however when the client first logs in to the session, because the state of these items is controlled by the GM, they are "off" on the client side. The GM has to turn the item off/on for each client to send the OOB message etc.
Is there a way for the host to recognise a connection and send the OOB messages immediately?
damned
July 5th, 2021, 15:37
You could try:
onLogin
function onLogin(username, activated)
Registered functions on this handler are called whenever a user logs in to or out of the running session.
Parameters
username (string)
The username of the connecting/disconnecting client
activated (boolean)
This value is true if the user is logging on, or false if the user is logging off
UrsaTeddy
July 5th, 2021, 23:44
I did look at that, however I would need to know the username of the person logging in wouldn't I?
I am really looking for the client to say "hi I am here".
Moon Wizard
July 6th, 2021, 02:17
The onLogin is a handler that you register a callback function to listen for, and gets passed the username parameter.
Search through CoreRPG ruleset for an example of registering a handler; and handling the callback.
Regards,
JPG
UrsaTeddy
July 6th, 2021, 03:01
Okay, so I looked through CoreRPG and found only one location that it is used - scripts/data_desktop.lua/onInit
The setup sets the callback User.onLogin to a function in that script - User.onLogin = onUserLogin
If I takeover that callback with my own code - for example User.onLogin = myOnUserLogin, the default function will not execute, am I correct?
I can ensure that the default code executes without an issue, however this still will cause problems in the future with any other extensions that hook User.onLogin.
Have I understood that correctly?
Trenloe
July 6th, 2021, 14:38
So far it works as intended, however when the client first logs in to the session, because the state of these items is controlled by the GM, they are "off" on the client side. The GM has to turn the item off/on for each client to send the OOB message etc.
If the options are GM options, and not options that players can control, then when a player logs in the code should have access to the current options.
Something to consider:
1) Writing code that triggers when the client logs in. You can do this on the player side, but pass processing to the GM via OOB messaging or keep it locally if that's what you need (which it sounds like it is).. This may be simpler than triggering directly on the GM side via the onLogin event.
2) And, having your current code that runs if the GM changes the option while players are connected.
UrsaTeddy
July 6th, 2021, 15:22
The properties are GM only (turn property on/off, set a name for the property).
I solved it with the client sending a "hi I am here" OOB to the host which then triggers an update/refresh for the client.
I was actually able to also refresh any open character sheets since the options in question create/destroy character sheet fields.
The comments here have been very helpful.
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.