Source: models/rooms/remote.js

  1. "use strict";
  2. /**
  3. * Create a remote room.
  4. * @constructor
  5. * @param {string} identifier The ID for this room
  6. * @param {Object=} data The key-value data object to assign to this room.
  7. */
  8. function RemoteRoom(identifier, data) {
  9. this.roomId = identifier;
  10. this.data = data || {};
  11. }
  12. /**
  13. * Get the room ID.
  14. * @return {string} The room ID
  15. */
  16. RemoteRoom.prototype.getId = function() {
  17. return this.roomId;
  18. };
  19. /**
  20. * Serialize all the data about this room, excluding the room ID.
  21. * @return {Object} The serialised data
  22. */
  23. RemoteRoom.prototype.serialize = function() {
  24. return this.data;
  25. };
  26. /**
  27. * Get the data value for the given key.
  28. * @param {string} key An arbitrary bridge-specific key.
  29. * @return {*} Stored data for this key. May be undefined.
  30. */
  31. RemoteRoom.prototype.get = function(key) {
  32. return this.data[key];
  33. };
  34. /**
  35. * Set an arbitrary bridge-specific data value for this room.
  36. * @param {string} key The key to store the data value under.
  37. * @param {*} val The data value. This value should be serializable via
  38. * <code>JSON.stringify(data)</code>.
  39. */
  40. RemoteRoom.prototype.set = function(key, val) {
  41. this.data[key] = val;
  42. };
  43. /** The RemoteRoom class. */
  44. module.exports = RemoteRoom;