Class: MTProto::Type::BadMsgNotification

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

Constant Summary collapse

CONSTRUCTOR =
0xa7eff811

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bad_msg_id:, bad_msg_seqno:, error_code:) ⇒ BadMsgNotification

Returns a new instance of BadMsgNotification.



23
24
25
26
27
# File 'lib/mtproto/type/bad_msg_notification.rb', line 23

def initialize(bad_msg_id:, bad_msg_seqno:, error_code:)
  @bad_msg_id = bad_msg_id
  @bad_msg_seqno = bad_msg_seqno
  @error_code = error_code
end

Instance Attribute Details

#bad_msg_idObject (readonly)

Returns the value of attribute bad_msg_id.



8
9
10
# File 'lib/mtproto/type/bad_msg_notification.rb', line 8

def bad_msg_id
  @bad_msg_id
end

#bad_msg_seqnoObject (readonly)

Returns the value of attribute bad_msg_seqno.



8
9
10
# File 'lib/mtproto/type/bad_msg_notification.rb', line 8

def bad_msg_seqno
  @bad_msg_seqno
end

#error_codeObject (readonly)

Returns the value of attribute error_code.



8
9
10
# File 'lib/mtproto/type/bad_msg_notification.rb', line 8

def error_code
  @error_code
end

Class Method Details

.deserialize(data) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mtproto/type/bad_msg_notification.rb', line 10

def self.deserialize(data)
  offset = 4
  bad_msg_id = data[offset, 8].unpack1('Q<')
  offset += 8

  bad_msg_seqno = data[offset, 4].unpack1('L<')
  offset += 4

  error_code = data[offset, 4].unpack1('L<')

  new(bad_msg_id: bad_msg_id, bad_msg_seqno: bad_msg_seqno, error_code: error_code)
end

Instance Method Details

#error_messageObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/mtproto/type/bad_msg_notification.rb', line 29

def error_message
  case @error_code
  when 16 then "msg_id too low (client time is wrong)"
  when 17 then "msg_id too high (client time needs sync)"
  when 18 then "incorrect two lower order msg_id bits (must be divisible by 4)"
  when 19 then "container msg_id is the same as previously received"
  when 20 then "message too old"
  when 32 then "msg_seqno too low"
  when 33 then "msg_seqno too high"
  when 34 then "even msg_seqno expected but odd received"
  when 35 then "odd msg_seqno expected but even received"
  when 48 then "incorrect server salt"
  else "unknown error code #{@error_code}"
  end
end