Class: Overlook::Csgo::Demo::UserMessageMessageHandler
- Inherits:
-
Object
- Object
- Overlook::Csgo::Demo::UserMessageMessageHandler
- Includes:
- SteamIDs
- Defined in:
- lib/overlook/csgo/demo/user_message_message_handler.rb
Instance Method Summary collapse
- #handle(message) ⇒ Object
-
#initialize(parser) ⇒ UserMessageMessageHandler
constructor
A new instance of UserMessageMessageHandler.
Constructor Details
#initialize(parser) ⇒ UserMessageMessageHandler
Returns a new instance of UserMessageMessageHandler.
9 10 11 |
# File 'lib/overlook/csgo/demo/user_message_message_handler.rb', line 9 def initialize(parser) @parser = parser end |
Instance Method Details
#handle(message) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/overlook/csgo/demo/user_message_message_handler.rb', line 13 def handle() = ::Csgo::CSVCMsg_UserMessage.decode() case .msg_type when ::Csgo::ECstrike15UserMessages::CS_UM_XpUpdate = ::Csgo::CCSUsrMsg_XpUpdate.decode(.msg_data) community_id = SteamID32.parse("[U:1:#{.data.account_id}]").to_steamID64.to_s xp_update = { community_id => { xp: .data.current_xp, lvl: .data.current_level, progress: .data.xp_progress_data.map do |item| { category: item.xp_category, xp: item.xp_points } end } } @parser.emit(:xp_update, xp_update) when ::Csgo::ECstrike15UserMessages::CS_UM_ServerRankUpdate = ::Csgo::CCSUsrMsg_ServerRankUpdate.decode(.msg_data) .rank_update.each do |update| # The account_id is used in the 'modern' steam format. # [U:1:account_id] community_id = SteamID32.parse("[U:1:#{update.account_id}]").to_steamID64.to_s rank_update_payload = { rank_change: update.rank_change.to_i, wins: update.num_wins, community_id: community_id, rank: update.rank_new } @parser.emit(:rank_update, rank_update_payload) end end end |