Subject | Re: which user are coonected' |
---|---|
Author | Adam |
Post date | 2007-10-07T23:38:50Z |
--- In firebird-support@yahoogroups.com, "Codebue Fabio - P-Soft"
<f.codebue@...> wrote:
Superserver does have such a call, but Classic Server will only ever
return 1 regardless of how many connections are made, and considering
the SMP weaknesses of Superserver it would be quite unwise (and in
practice just as hard) to prevent your customers from using Classic.
For Classic, you can simply count the number of fb_inet_server
processes (and subtract 1 on Windows), but this is ALL Firebird
connections, NOT just those connections to a specific database. If you
are using such a mechanism for your own applications license
restrictions, then you need to be aware that other applications on
your system may also use Firebird. If you are only using it as an
estimation to troubleshoot some problem, it may be good enough.
If you want to count this from within your application, the difficulty
depends on your application architecture. If you have an n-tier
structure it is pretty trivial. Your data access layer can count how
many clients are connected and you wouldn't even care what database
engine was used.
If you have a client-server architecture, it is much more tricky. Your
best chance IMO would be to have your application store CURRENT_USER
in a table in the login process, and create a secondary thread to
refresh a timestamp next to that record every couple of minutes. You
can periodically clear out records which have a timestamp that is 'too
old' (presumed ungraceful exit). Of course your secondary thread needs
to establish its own database connection too.
Adam
<f.codebue@...> wrote:
>There is no reliable way of achieving this within Firebird itself.
> How can I know which user are connected?
> There is a service api to call?
> How can enumerate users are connected to firebird trow delphi code?
Superserver does have such a call, but Classic Server will only ever
return 1 regardless of how many connections are made, and considering
the SMP weaknesses of Superserver it would be quite unwise (and in
practice just as hard) to prevent your customers from using Classic.
For Classic, you can simply count the number of fb_inet_server
processes (and subtract 1 on Windows), but this is ALL Firebird
connections, NOT just those connections to a specific database. If you
are using such a mechanism for your own applications license
restrictions, then you need to be aware that other applications on
your system may also use Firebird. If you are only using it as an
estimation to troubleshoot some problem, it may be good enough.
If you want to count this from within your application, the difficulty
depends on your application architecture. If you have an n-tier
structure it is pretty trivial. Your data access layer can count how
many clients are connected and you wouldn't even care what database
engine was used.
If you have a client-server architecture, it is much more tricky. Your
best chance IMO would be to have your application store CURRENT_USER
in a table in the login process, and create a secondary thread to
refresh a timestamp next to that record every couple of minutes. You
can periodically clear out records which have a timestamp that is 'too
old' (presumed ungraceful exit). Of course your secondary thread needs
to establish its own database connection too.
Adam