DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: webb123
今日帖子: 10
在线用户: 24
导航: 论坛 -> 移动应用开发 斑竹:flyers,iamdream  
作者:
男 sxfgf (FC_FGF) ★☆☆☆☆ -
普通会员
2023/2/23 11:37:46
标题:
snap 服务器端检测连接用户数的问题 浏览:551
加入我的收藏
楼主: 目的是当客户登录时,显示目前登录用户数,退出时将登录数减一
用来限制客户的用户数,比如3用户的客户,同时只能有3台设备登录
第4台不能登录;
现在的问题是:登录后可以+1;App退出后不会减一

这样的问题应该如何处理呢?
或者方法有错?

var linkusercount:integer;
..........
function TFc_Server_SM_Fm.GetUserCount: Integer;
begin
  REsult:=linkusercount;
end;

//建立连接 + 1
procedure TFc_Server_SM_Fm.FDConnection1AfterConnect(Sender: TObject);
begin
 linkusercount:=linkusercount+1;
end;

//关闭连接 -1
procedure TFc_Server_SM_Fm.FDConnection1AfterDisconnect(Sender: TObject);
begin
  linkusercount:=linkusercount-1;
end;
----------------------------------------------
偶尔做做代码应付一下工作,却发现Delphi已成必配
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2023/2/23 22:10:42
1楼: I think you could keep a user count list on the server. And update it as per your requirement.

This way, when trying to connect, the Server consults its list and accepts or rejects the new connection.

+/-  that way:

Server:
  MyConnections_List = User-name, ConnectionCount

...
event New Connection On The Server:
----------
   If MyConnections_List.USERXXXX_EXIST and MyConnections_List.USERXXXX.Count > 3 then
      REFUSE
   else
      MyConnections_List USERXXXX.Count = +1
----------
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 janker (janker) ★☆☆☆☆ -
盒子活跃会员
2023/2/23 22:38:13
2楼: TDSServer 有OnConnect和OnDisConnect事件

通过参数DSConnectEventObject.ChannelInfo.ClientInfo获取客户端信息

如果不限制,一台电脑也可能有几个客户端登录
----------------------------------------------
-
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行74.21875毫秒 RSS