Disconnect on invalid snap item
Do not leave a timeouted tee on the server if the snap is parsed wrong
This commit is contained in:
parent
c28bcd15e8
commit
d4332ce6b0
|
@ -158,7 +158,7 @@ class GameClient
|
|||
end
|
||||
|
||||
def on_snapshot(chunk)
|
||||
u = SnapshotUnpacker.new
|
||||
u = SnapshotUnpacker.new(@client)
|
||||
snapshot = u.snap_single(chunk)
|
||||
|
||||
return if snapshot.nil?
|
||||
|
|
|
@ -29,6 +29,10 @@ class Snapshot
|
|||
end
|
||||
|
||||
class SnapshotUnpacker
|
||||
def initialize(client)
|
||||
@client = client
|
||||
end
|
||||
|
||||
def snap_single(chunk)
|
||||
u = Unpacker.new(chunk.data)
|
||||
msg_id = u.get_int
|
||||
|
@ -195,6 +199,7 @@ class SnapshotUnpacker
|
|||
end
|
||||
end
|
||||
puts 'Error: got invalid snap item'
|
||||
@client.disconnect
|
||||
exit 1
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue