Module: MTProto::TL::Peers

Defined in:
lib/mtproto/tl/peers.rb

Defined Under Namespace

Classes: Chat

Constant Summary collapse

CHAT_EMPTY =
0x29562865
USER_EMPTY =
0xd3bc4b7a

Class Method Summary collapse

Class Method Details

.chats_at(data, offset) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mtproto/tl/peers.rb', line 12

def chats_at(data, offset)
  offset += 4 # vector constructor
  count = data[offset, 4].unpack1('L<')
  offset += 4

  chats = []
  count.times do
    chat, offset = parse_chat(data, offset)
    chats << chat if chat
  end
  [chats, offset]
end

.users_at(data, offset) ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/mtproto/tl/peers.rb', line 147

def users_at(data, offset)
  offset += 4 # vector constructor
  count = data[offset, 4].unpack1('L<')
  offset += 4

  users = []
  count.times do
    user, offset = parse_user(data, offset)
    users << user if user
  end
  [users, offset]
end