修改单元: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;