RTC,登陆后添加权限值
Posted Delphi技术积累
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RTC,登陆后添加权限值相关的知识,希望对你有一定的参考价值。
修改单元:rtcMW.DM.Main;
修改组件:fnLogin
在方法中添加:
服务端:
const
SQL_SELECT_USER = ‘SELECT * FROM Users WHERE UserName=:UserName‘;
with TRtcHttpServer(Sender) do
begin
// OpenSession();
Session.asText[‘UserName‘] := UserName;
Session.asText[‘UserID‘] := FieldByName(‘UserID‘).AsString;
Session.asText[‘ConnectionDefName‘] := ConnectionDef.Name;
Result.asRecord.asText[‘token‘] := Session.ID.ToLower;
Result.asRecord.asInteger[‘UploadFileSizeMax‘] := UploadFileSizeMax;
Result.asRecord.asString[‘Permission‘] := FieldByName(‘permission‘).AsString; //添加此
end;
编译服务端
客户端
文件:rtcMW.Comp.Client
1.
private
FPermission:string; //权限
public
property Permission:string read FPermission write FPermission; //权限
function TRFConnection.DoLoginResult(Value: TRtcValue): Boolean;
begin
Result := False;
FAccessToken := EmptyStr;
if Value.isType = rtc_Record then
begin
FUserLoginState := TUserLoginState(Value.asRecord.asInteger[‘LoginState‘]);
Result := FUserLoginState = lsSucceed;
if Result then
begin
FAccessToken := Value.asRecord.asText[‘Token‘];
FUploadFileSizeMax := Value.asRecord.asInteger[‘UploadFileSizeMax‘];
FPermission:=Value.asRecord.asString[‘Permission‘]; //权限 新增
end;
if Assigned(FUserLoginEvent) then
FUserLoginEvent(FUserLoginState, FAccessToken);
end
else if Value.isType = rtc_Exception then
raise Exception.Create(Value.asException);
end;
以上是关于RTC,登陆后添加权限值的主要内容,如果未能解决你的问题,请参考以下文章