Sha256: 7f10c14330eb1ad75c5bfc87d1d608f44e2c3949618b081f4714b4bbd86b0a59

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true
module Steam
  module Protocol
    # Represents a Protobuf message. They have a protobuf header, and body.
    # Their emsg is masked with the PROTO_MASK flag
    class ProtobufMessage
      include Message

      # A Protobuf Message contains a steam id and a session id. It also uses
      # the PROTO_MASK on the EMsg.
      def initialize(header, body, emsg)
        super(header, body, emsg | PROTO_MASK)
      end

      # Returns the masked protobuf emsg
      def emsg
        @emsg & ~PROTO_MASK
      end

      # Get the steam_id associated with this message
      #
      # @return [Integer]
      def steam_id
        @header.proto.steamid
      end

      #
      # Get the steam_id associated with this message
      #
      # @return [Integer]
      def session_id
        @header.proto.client_sessionid
      end

      # The steam id associated with the message
      #
      # @param sid [String] the Steam id
      def steam_id=(sid)
        @header.proto.steamid = sid
      end

      # The session id associated with the message
      #
      # @param sid [String] the Session id
      def session_id=(sid)
        @header.proto.client_sessionid = sid
      end

      def proto?
        true
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
steamrb-0.1.3 lib/steam/protocol/protobuf_message.rb
steamrb-0.1.2 lib/steam/protocol/protobuf_message.rb
steamrb-0.1.1 lib/steam/protocol/protobuf_message.rb
steamrb-0.1.0 lib/steam/protocol/protobuf_message.rb