Class: MTProto::TL::DHGenResponse

Inherits:
Object
  • Object
show all
Extended by:
Binary
Defined in:
lib/mtproto/tl/objects/dh_gen_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from Binary

b_u32, b_u64, u32_b, u64_b

Instance Attribute Details

#new_nonce_hashObject (readonly)

Returns the value of attribute new_nonce_hash.



8
9
10
# File 'lib/mtproto/tl/objects/dh_gen_response.rb', line 8

def new_nonce_hash
  @new_nonce_hash
end

#nonceObject (readonly)

Returns the value of attribute nonce.



8
9
10
# File 'lib/mtproto/tl/objects/dh_gen_response.rb', line 8

def nonce
  @nonce
end

#server_nonceObject (readonly)

Returns the value of attribute server_nonce.



8
9
10
# File 'lib/mtproto/tl/objects/dh_gen_response.rb', line 8

def server_nonce
  @server_nonce
end

#statusObject (readonly)

Returns the value of attribute status.



8
9
10
# File 'lib/mtproto/tl/objects/dh_gen_response.rb', line 8

def status
  @status
end

Class Method Details

.deserialize(message) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mtproto/tl/objects/dh_gen_response.rb', line 10

def self.deserialize(message)
  data = message.body
  constructor = b_u32(data[0, 4])

  status = case constructor
           when Constructors::DH_GEN_OK then :ok
           when Constructors::DH_GEN_RETRY then :retry
           when Constructors::DH_GEN_FAIL then :fail
           else raise "Unexpected constructor: 0x#{constructor.to_s(16)}"
           end

  offset = 4
  nonce = data[offset, 16].pack('C*')
  offset += 16
  server_nonce = data[offset, 16].pack('C*')
  offset += 16
  new_nonce_hash = data[offset, 16].pack('C*')

  new(
    status: status,
    nonce: nonce,
    server_nonce: server_nonce,
    new_nonce_hash: new_nonce_hash
  )
end