Class: Agora::AgoraDynamicKey2::Service
- Inherits:
-
Object
- Object
- Agora::AgoraDynamicKey2::Service
- Defined in:
- lib/agora/dynamic_key2/access_token.rb
Direct Known Subclasses
ServiceApaas, ServiceChat, ServiceFpa, ServiceRtc, ServiceRtm
Instance Attribute Summary collapse
-
#privileges ⇒ Object
Returns the value of attribute privileges.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #add_privilege(privilege, expire) ⇒ Object
- #fetch_uid(uid) ⇒ Object
-
#initialize(type) ⇒ Service
constructor
A new instance of Service.
- #pack ⇒ Object
- #unpack(data) ⇒ Object
Constructor Details
#initialize(type) ⇒ Service
Returns a new instance of Service.
9 10 11 12 |
# File 'lib/agora/dynamic_key2/access_token.rb', line 9 def initialize(type) @type = type @privileges = {} end |
Instance Attribute Details
#privileges ⇒ Object
Returns the value of attribute privileges.
7 8 9 |
# File 'lib/agora/dynamic_key2/access_token.rb', line 7 def privileges @privileges end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/agora/dynamic_key2/access_token.rb', line 7 def type @type end |
Instance Method Details
#add_privilege(privilege, expire) ⇒ Object
14 15 16 |
# File 'lib/agora/dynamic_key2/access_token.rb', line 14 def add_privilege(privilege, expire) @privileges[privilege] = expire end |
#fetch_uid(uid) ⇒ Object
18 19 20 21 22 |
# File 'lib/agora/dynamic_key2/access_token.rb', line 18 def fetch_uid(uid) return '' if uid.eql?(0) uid.to_s end |
#pack ⇒ Object
24 25 26 |
# File 'lib/agora/dynamic_key2/access_token.rb', line 24 def pack Util.pack_uint16(@type) + Util.pack_map_uint32(@privileges) end |
#unpack(data) ⇒ Object
28 29 30 |
# File 'lib/agora/dynamic_key2/access_token.rb', line 28 def unpack(data) @privileges, data = Util.unpack_map_uint32(data) end |