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