Class: Agora::AgoraDynamicKey2::ChatTokenBuilder
- Inherits:
-
Object
- Object
- Agora::AgoraDynamicKey2::ChatTokenBuilder
- Defined in:
- lib/agora/dynamic_key2/chat_token_builder.rb
Class Method Summary collapse
-
.build_app_token(app_id, app_certificate, expire) ⇒ Object
Build the Chat App token.
-
.build_user_token(app_id, app_certificate, user_id, expire) ⇒ Object
Build the Chat user token.
Class Method Details
.build_app_token(app_id, app_certificate, expire) ⇒ Object
Build the Chat App token.
32 33 34 35 36 37 38 39 40 |
# File 'lib/agora/dynamic_key2/chat_token_builder.rb', line 32 def self.build_app_token(app_id, app_certificate, expire) access_token = Agora::AgoraDynamicKey2::AccessToken.new(app_id, app_certificate, expire) service_chat = Agora::AgoraDynamicKey2::ServiceChat.new service_chat.add_privilege(Agora::AgoraDynamicKey2::ServiceChat::PRIVILEGE_APP, expire) access_token.add_service(service_chat) access_token.build end |
.build_user_token(app_id, app_certificate, user_id, expire) ⇒ Object
Build the Chat user token.
13 14 15 16 17 18 19 20 21 |
# File 'lib/agora/dynamic_key2/chat_token_builder.rb', line 13 def self.build_user_token(app_id, app_certificate, user_id, expire) access_token = Agora::AgoraDynamicKey2::AccessToken.new(app_id, app_certificate, expire) service_chat = Agora::AgoraDynamicKey2::ServiceChat.new(user_id) service_chat.add_privilege(Agora::AgoraDynamicKey2::ServiceChat::PRIVILEGE_USER, expire) access_token.add_service(service_chat) access_token.build end |