You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.7 KiB

  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Talk\Model;
  8. use OCP\AppFramework\Db\Entity;
  9. use OCP\DB\Types;
  10. /**
  11. * A session is the "I'm online in this conversation" state of Talk, you get one
  12. * when opening the conversation while the inCall flag tells if you are just
  13. * online (chatting), or in a call (with audio, camera or even sip).
  14. *
  15. * @method void setAttendeeId(int $attendeeId)
  16. * @method string getAttendeeId()
  17. * @method void setSessionId(string $sessionId)
  18. * @method string getSessionId()
  19. * @method void setInCall(int $inCall)
  20. * @method int getInCall()
  21. * @method void setLastPing(int $lastPing)
  22. * @method int getLastPing()
  23. * @method void setState(int $state)
  24. * @method int getState()
  25. */
  26. class Session extends Entity {
  27. public const STATE_INACTIVE = 0;
  28. public const STATE_ACTIVE = 1;
  29. public const SESSION_TIMEOUT = 30;
  30. public const SESSION_TIMEOUT_KILL = self::SESSION_TIMEOUT * 3 + 10;
  31. /** @var int */
  32. protected $attendeeId;
  33. /** @var string */
  34. protected $sessionId;
  35. /** @var int */
  36. protected $inCall;
  37. /** @var int */
  38. protected $lastPing;
  39. /** @var int */
  40. protected $state;
  41. public function __construct() {
  42. $this->addType('attendeeId', Types::BIGINT);
  43. $this->addType('sessionId', Types::STRING);
  44. $this->addType('inCall', Types::INTEGER);
  45. $this->addType('lastPing', Types::INTEGER);
  46. $this->addType('state', Types::SMALLINT);
  47. }
  48. /**
  49. * @return array
  50. */
  51. public function asArray(): array {
  52. return [
  53. 'id' => $this->getId(),
  54. 'attendee_id' => $this->getAttendeeId(),
  55. 'session_id' => $this->getSessionId(),
  56. 'in_call' => $this->getInCall(),
  57. 'last_ping' => $this->getLastPing(),
  58. ];
  59. }
  60. }