session.dart 966 B

1234567891011121314151617181920212223242526272829303132333435
  1. import 'dart:core';
  2. import '../client_base.dart';
  3. import 'package:fis_common/json_convert.dart';
  4. import 'session.m.dart';
  5. class SessionService extends JsonRpcClientBase {
  6. SessionService(
  7. String host, {
  8. String serviceName = "ISessionService",
  9. Map<String, String>? headers,
  10. int? timeout,
  11. }) : super(
  12. host,
  13. serviceName,
  14. headers: headers,
  15. timeout: timeout,
  16. ) {
  17. /// 注册响应实体反序列化处理器
  18. FJsonConvert.setDecoder((map) => SessionInfo.fromJson(map));
  19. }
  20. Future<SessionInfo> createSessionAsync(
  21. String userCode, SessionClientInfo clientInfo) async {
  22. var rpcRst = await call("CreateSessionAsync", [userCode, clientInfo]);
  23. var result = SessionInfo.fromJson(rpcRst as Map<String, dynamic>);
  24. return result;
  25. }
  26. Future<bool> removeSessionAsync(String sessionId) async {
  27. var rpcRst = await call("RemoveSessionAsync", sessionId);
  28. return rpcRst;
  29. }
  30. }