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
Constant Summary collapse
- SERVER_RANK_UPDATE_MESSAGE_TYPE =
52- XP_UPDATE_MESSAGE_TYPE =
65- SEND_PLAYER_ITEM_DROP_MESSAGE_TYPE =
61
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.
13 14 15 |
# File 'lib/overlook/csgo/demo/user_message_message_handler.rb', line 13 def initialize(parser) @parser = parser end |
Instance Method Details
#handle(message) ⇒ Object
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 47 48 49 50 51 52 |
# File 'lib/overlook/csgo/demo/user_message_message_handler.rb', line 17 def handle() = CSVCMsg_UserMessage.decode() case .msg_type when SEND_PLAYER_ITEM_DROP_MESSAGE_TYPE # nop when XP_UPDATE_MESSAGE_TYPE = CCSUsrMsg_XpUpdate.decode(.msg_data) community_id = SteamID32.parse("[U:1:#{xp_update_message.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 SERVER_RANK_UPDATE_MESSAGE_TYPE = 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 |