21 lines
634 B
Crystal
21 lines
634 B
Crystal
# 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
|