Class: Agora::AgoraDynamicKey2::ServiceApaas

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

Constant Summary collapse

SERVICE_TYPE =
7
PRIVILEGE_ROOM_USER =
1
PRIVILEGE_USER =
2
PRIVILEGE_APP =
3

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(room_uuid = '', user_uuid = '', role = -1)) ⇒ ServiceApaas

Returns a new instance of ServiceApaas.



127
128
129
130
131
132
# File 'lib/agora/dynamic_key2/access_token.rb', line 127

def initialize(room_uuid = '', user_uuid = '', role = -1)
  super(SERVICE_TYPE)
  @room_uuid = room_uuid
  @user_uuid = user_uuid
  @role = role
end

Instance Attribute Details

#roleObject

Returns the value of attribute role.



120
121
122
# File 'lib/agora/dynamic_key2/access_token.rb', line 120

def role
  @role
end

#room_uuidObject

Returns the value of attribute room_uuid.



120
121
122
# File 'lib/agora/dynamic_key2/access_token.rb', line 120

def room_uuid
  @room_uuid
end

#user_uuidObject

Returns the value of attribute user_uuid.



120
121
122
# File 'lib/agora/dynamic_key2/access_token.rb', line 120

def user_uuid
  @user_uuid
end

Instance Method Details

#packObject



134
135
136
# File 'lib/agora/dynamic_key2/access_token.rb', line 134

def pack
  super() + Util.pack_string(@room_uuid) + Util.pack_string(@user_uuid) + Util.pack_int16(@role)
end

#unpack(data) ⇒ Object



138
139
140
141
142
143
# File 'lib/agora/dynamic_key2/access_token.rb', line 138

def unpack(data)
  _, data = super(data)
  @room_uuid, data = Util.unpack_string(data)
  @user_uuid, data = Util.unpack_string(data)
  @role, data = Util.unpack_int16(data)
end