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
|
end
|
||||||
|
|
||||||
def on_snapshot(chunk)
|
def on_snapshot(chunk)
|
||||||
u = SnapshotUnpacker.new
|
u = SnapshotUnpacker.new(@client)
|
||||||
snapshot = u.snap_single(chunk)
|
snapshot = u.snap_single(chunk)
|
||||||
|
|
||||||
return if snapshot.nil?
|
return if snapshot.nil?
|
||||||
|
|
|
@ -29,6 +29,10 @@ class Snapshot
|
||||||
end
|
end
|
||||||
|
|
||||||
class SnapshotUnpacker
|
class SnapshotUnpacker
|
||||||
|
def initialize(client)
|
||||||
|
@client = client
|
||||||
|
end
|
||||||
|
|
||||||
def snap_single(chunk)
|
def snap_single(chunk)
|
||||||
u = Unpacker.new(chunk.data)
|
u = Unpacker.new(chunk.data)
|
||||||
msg_id = u.get_int
|
msg_id = u.get_int
|
||||||
|
@ -195,6 +199,7 @@ class SnapshotUnpacker
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
puts 'Error: got invalid snap item'
|
puts 'Error: got invalid snap item'
|
||||||
|
@client.disconnect
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue