Class: MTProto::Type::PQInnerData

Inherits:
Object
  • Object
show all
Defined in:
lib/mtproto/type/pq_inner_data.rb

Constant Summary collapse

CONSTRUCTOR_DC =
0xa9f55f95
CONSTRUCTOR_TEMP_DC =
0x56fddf88

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pq:, p:, q:, nonce:, server_nonce:, new_nonce:, dc:, expires_in: nil) ⇒ PQInnerData

Returns a new instance of PQInnerData.



13
14
15
16
17
18
19
20
21
22
# File 'lib/mtproto/type/pq_inner_data.rb', line 13

def initialize(pq:, p:, q:, nonce:, server_nonce:, new_nonce:, dc:, expires_in: nil)
  @pq = pq
  @p = p
  @q = q
  @nonce = nonce
  @server_nonce = server_nonce
  @new_nonce = new_nonce
  @dc = dc
  @expires_in = expires_in
end

Instance Attribute Details

#dcObject (readonly)

Returns the value of attribute dc.



11
12
13
# File 'lib/mtproto/type/pq_inner_data.rb', line 11

def dc
  @dc
end

#expires_inObject (readonly)

Returns the value of attribute expires_in.



11
12
13
# File 'lib/mtproto/type/pq_inner_data.rb', line 11

def expires_in
  @expires_in
end

#new_nonceObject (readonly)

Returns the value of attribute new_nonce.



11
12
13
# File 'lib/mtproto/type/pq_inner_data.rb', line 11

def new_nonce
  @new_nonce
end

#nonceObject (readonly)

Returns the value of attribute nonce.



11
12
13
# File 'lib/mtproto/type/pq_inner_data.rb', line 11

def nonce
  @nonce
end

#pObject (readonly)

Returns the value of attribute p.



11
12
13
# File 'lib/mtproto/type/pq_inner_data.rb', line 11

def p
  @p
end

#pqObject (readonly)

Returns the value of attribute pq.



11
12
13
# File 'lib/mtproto/type/pq_inner_data.rb', line 11

def pq
  @pq
end

#qObject (readonly)

Returns the value of attribute q.



11
12
13
# File 'lib/mtproto/type/pq_inner_data.rb', line 11

def q
  @q
end

#server_nonceObject (readonly)

Returns the value of attribute server_nonce.



11
12
13
# File 'lib/mtproto/type/pq_inner_data.rb', line 11

def server_nonce
  @server_nonce
end

Instance Method Details

#serializeObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/mtproto/type/pq_inner_data.rb', line 24

def serialize
  constructor = @expires_in ? CONSTRUCTOR_TEMP_DC : CONSTRUCTOR_DC

  data = Serializer.serialize_int(constructor)
  data += Serializer.serialize_bytes(Serializer.integer_to_bytes(@pq))
  data += Serializer.serialize_bytes(Serializer.integer_to_bytes(@p))
  data += Serializer.serialize_bytes(Serializer.integer_to_bytes(@q))
  data += @nonce
  data += @server_nonce
  data += @new_nonce

  data += Serializer.serialize_int(@expires_in) if @expires_in

  data + Serializer.serialize_int(@dc)
end