导航:
论坛 -> 移动应用开发
斑竹: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已成必配
作者:
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获取客户端信息 如果不限制,一台电脑也可能有几个客户端登录
----------------------------------------------
-