Class: MyApp::PlayerHandler
- Inherits:
-
RubyPitaya::HandlerBase
- Object
- RubyPitaya::HandlerBase
- MyApp::PlayerHandler
- Defined in:
- lib/rubypitaya/app-template/app/handlers/player_handler.rb
Instance Attribute Summary
Attributes inherited from RubyPitaya::HandlerBase
#bll, #config, #log, #params, #postman, #redis, #session, #setup
Instance Method Summary collapse
Methods inherited from RubyPitaya::HandlerBase
authenticated_action_name?, #initialize, non_authenticated_actions
Constructor Details
This class inherits a constructor from RubyPitaya::HandlerBase
Instance Method Details
#authenticate ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rubypitaya/app-template/app/handlers/player_handler.rb', line 48 def authenticate user_id = @params[:userId] player = Player.find_by_user_id(user_id) player = @bll[:player].create_new_player(@setup, @config) if player.nil? @session.uid = player.user_id bind_session_response = @postman.bind_session(@session) unless bind_session_response.dig(:error, :code).nil? return response = { code: RubyPitaya::StatusCodes::CODE_AUTHENTICATION_ERROR, msg: 'Error to authenticate', } end response = { code: StatusCodes::CODE_OK, data: player.to_hash, } end |
#getInfo ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rubypitaya/app-template/app/handlers/player_handler.rb', line 71 def getInfo user_id = @session.uid player = Player.find_by_user_id(user_id) response = { code: StatusCodes::CODE_OK, data: player.to_hash, } end |