instance_storage
parent
e636ae5c26
commit
9c9a3231bd
|
@ -0,0 +1,20 @@
|
|||
# Link between fd and TCPSocket, WebSocket and IPC::Connection instances.
|
||||
class InstanceStorage
|
||||
property is_json : Hash(Int32, Bool)
|
||||
property fd_to_websocket : Hash(Int32, WebSocket)
|
||||
|
||||
def initialize
|
||||
# fdlist_client = [] of TCPSocket
|
||||
@is_json = Hash(Int32,Bool).new
|
||||
@fd_to_websocket = Hash(Int32, WebSocket).new
|
||||
end
|
||||
|
||||
def remove_fd (fdclient : Int32)
|
||||
puts "#{CBLUE}closing the client:#{CRESET} #{fdclient}"
|
||||
# 1. remove the client and the service from is_json
|
||||
@is_json.select! do |fd,v| fd != fdclient end
|
||||
|
||||
# 2. remove the client from fd_to_websocket
|
||||
@fd_to_websocket.select! do |fd, ws| fd != fdclient end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue