3
0
Fork 0

websocketd: buffered read is not a problem anymore.

dev
Karchnu 2020-08-03 00:28:23 +02:00
parent 3d0687554b
commit 209690d9e4
1 changed files with 8 additions and 2 deletions

View File

@ -154,7 +154,7 @@ def handle_new_clients(service, server)
# LibIPC.ipc_connection_switched service.pointer, req_service, client.fd, Pointer(Libc::Int).null
LibIPC.ipc_connection_switched service.pointer, req_service, client.fd, pointerof (serverfd)
proc_cb_in = ->ws_cb_in(Int32, Pointer(LibIPC::Message))
proc_cb_in = ->ws_cb_in(Int32, Pointer(LibIPC::Message), Int16*)
proc_cb_out = ->ws_cb_out(Int32, Pointer(LibIPC::Message))
# 4. change client callbacks via ipc_switching_callbacks
@ -191,7 +191,7 @@ rescue e
return LibIPC::IPCCB::Error
end
def ws_cb_in(fd : Int32, pm : LibIPC::Message*)
def ws_cb_in(fd : Int32, pm : LibIPC::Message*, more_to_read : Int16*)
info "IN fd is #{fd}"
wsclient = Context.context.fd_to_websocket[fd]
@ -205,6 +205,12 @@ def ws_cb_in(fd : Int32, pm : LibIPC::Message*)
return LibIPC::IPCCB::Error
end
if wsclient.ws.io.empty?
more_to_read[0] = 0
else
more_to_read[0] = 1
end
if wsclient.closed?
info "#{CBLUE}client is closed#{CRESET}"
Context.context.remove_fd fd