# File lib/net/ssh/transport/session.rb, line 165
165:     def poll_message(mode=:nonblock, consume_queue=true)
166:       loop do
167:         if consume_queue && @queue.any? && algorithms.allow?(@queue.first)
168:           return @queue.shift
169:         end
170: 
171:         packet = socket.next_packet(mode)
172:         return nil if packet.nil?
173: 
174:         case packet.type
175:         when DISCONNECT
176:           raise Net::SSH::Disconnect, "disconnected: #{packet[:description]} (#{packet[:reason_code]})"
177: 
178:         when IGNORE
179:           debug { "IGNORE packet recieved: #{packet[:data].inspect}" }
180: 
181:         when UNIMPLEMENTED
182:           lwarn { "UNIMPLEMENTED: #{packet[:number]}" }
183: 
184:         when DEBUG
185:           send(packet[:always_display] ? :fatal : :debug) { packet[:message] }
186: 
187:         when KEXINIT
188:           algorithms.accept_kexinit(packet)
189: 
190:         else
191:           return packet if algorithms.allow?(packet)
192:           push(packet)
193:         end
194:       end
195:     end