Class: Agora::AgoraDynamicKey2::ServiceRtc

Inherits:
Service
  • Object
show all
Defined in:
lib/agora/dynamic_key2/access_token.rb

Constant Summary collapse

SERVICE_TYPE =
1
PRIVILEGE_JOIN_CHANNEL =
1
PRIVILEGE_PUBLISH_AUDIO_STREAM =
2
PRIVILEGE_PUBLISH_VIDEO_STREAM =
3
PRIVILEGE_PUBLISH_DATA_STREAM =
4

Instance Attribute Summary collapse

Attributes inherited from Service

#privileges, #type

Instance Method Summary collapse

Methods inherited from Service

#add_privilege, #fetch_uid

Constructor Details

#initialize(channel_name = '', uid = '') ⇒ ServiceRtc



42
43
44
45
46
# File 'lib/agora/dynamic_key2/access_token.rb', line 42

def initialize(channel_name = '', uid = '')
  super(SERVICE_TYPE)
  @channel_name = channel_name
  @uid = fetch_uid(uid)
end

Instance Attribute Details

#channel_nameObject

Returns the value of attribute channel_name.



34
35
36
# File 'lib/agora/dynamic_key2/access_token.rb', line 34

def channel_name
  @channel_name
end

#uidObject

Returns the value of attribute uid.



34
35
36
# File 'lib/agora/dynamic_key2/access_token.rb', line 34

def uid
  @uid
end

Instance Method Details

#packObject



48
49
50
# File 'lib/agora/dynamic_key2/access_token.rb', line 48

def pack
  super() + Util.pack_string(@channel_name) + Util.pack_string(@uid)
end

#unpack(data) ⇒ Object



52
53
54
55
56
# File 'lib/agora/dynamic_key2/access_token.rb', line 52

def unpack(data)
  _, data = super(data)
  @channel_name, data = Util.unpack_string(data)
  @uid, data = Util.unpack_string(data)
end