class Steam::Csgo::Base

Handles CSGO related events

Attributes

client[R]

The Steam Client

Public Class Methods

new(client) click to toggle source

The Steam gem will instantiate the plugin and provide the client.

@param client [Steam::Client] the steam client

# File lib/steam/csgo/base.rb, line 12
def initialize(client)
  @client = client
end

Public Instance Methods

gc_message(msg) click to toggle source

The client will give us each gc message. We handle the ones we care about. A notice is printed on skipped emsgs

# File lib/steam/csgo/base.rb, line 58
def gc_message(msg)
  case msg.emsg
  when ::Csgo::EGCBaseClientMsg::K_EMsgGCClientWelcome
    client.csgo_ready
  when ::Csgo::ECsgoGCMsg::K_EMsgGCCStrike15_v2_MatchList
    match_list = msg.as(::Csgo::CMsgGCCStrike15_v2_MatchList)
    client.csgo_match_info(match_list)
  else
    Steam.logger.debug("[CS:GO] Ignoring msg: #{msg.emsg}")
  end
end
request_match_info(match_id, outcome_id, token) click to toggle source

Request match info for a given match.

@param match_id [String] the match id @param outcome_id [String] the outcome id @param token [String] the token

@return [Bool]

# File lib/steam/csgo/base.rb, line 23
def request_match_info(match_id, outcome_id, token)
  msg = ::Csgo::CMsgGCCStrike15_v2_MatchListRequestFullGameInfo.new
  msg.matchid = match_id
  msg.outcomeid = outcome_id
  msg.token = token

  msg = GcProtobufMessage.new(
    MsgGCHdrProtoBuf.new,
    msg,
    ::Csgo::ECsgoGCMsg::K_EMsgGCCStrike15_v2_MatchListRequestFullGameInfo
  )
  client.game_coordinator.send_msg(msg)
end
start() click to toggle source

Starts the plugin. Sets the Client to online and puts the Client into CS:GO

@return [Bool]

# File lib/steam/csgo/base.rb, line 41
def start
  client.steam_user.change_persona_state(EPersonaState::OFFLINE)
  client.game_coordinator.play(730)

  # actually ask and wait if we are in gc, but just sleep 10 seconds for
  # now
  sleep(5)

  client.game_coordinator.send_msg(
    GcProtobufMessage.new(MsgGCHdrProtoBuf.new,
                          ::Csgo::CMsgClientHello.new,
                          ::Csgo::EGCBaseClientMsg::K_EMsgGCClientHello)
  )
end