Fixes close() call on websockets.

master
Karchnu 2020-05-27 15:01:50 +02:00
parent a5e2e8f340
commit 2ddcdfb27b
3 changed files with 41 additions and 35 deletions

View File

@ -1,5 +1,5 @@
PACKAGE = 'plumberd' PACKAGE = 'ipcd'
VERSION = '0.1.0' VERSION = '0.2.1'
PREFIX := /usr/local PREFIX := /usr/local
BINDIR := $(PREFIX)/bin BINDIR := $(PREFIX)/bin
@ -8,13 +8,19 @@ SHAREDIR := $(PREFIX)/share
INCLUDEDIR := $(PREFIX)/include INCLUDEDIR := $(PREFIX)/include
MANDIR := $(SHAREDIR)/man MANDIR := $(SHAREDIR)/man
CRFLAGS := --release CRFLAGS := --release
CRFLAGS := --release
CRFLAGS := --release
CRFLAGS := --release
CRFLAGS := --release
CRFLAGS := --release
CRFLAGS := --release
Q := @ Q := @
all: tcpd tcpc pongd pongc plumberd websocketc websocketd all: tcpd tcpc pongd pongc ipcd websocketc websocketd
@: @:
tcpd: src/tcpd.cr tcpd: src/tcpd.cr
@echo ' CR > tcpd' @echo ' CR > tcpd'
$(Q)crystal build $(CRFLAGS) src/tcpd.cr -o 'tcpd' $(Q)crystal build $(CRFLAGS) src/tcpd.cr -o 'tcpd'
@ -32,7 +38,7 @@ tcpd.uninstall:
@echo ' RM > $(BINDIR)/tcpd' @echo ' RM > $(BINDIR)/tcpd'
$(Q)rm -f '$(DESTDIR)$(BINDIR)/tcpd' $(Q)rm -f '$(DESTDIR)$(BINDIR)/tcpd'
tcpc: src/tcpc.cr tcpc: src/tcpc.cr
@echo ' CR > tcpc' @echo ' CR > tcpc'
$(Q)crystal build $(CRFLAGS) src/tcpc.cr -o 'tcpc' $(Q)crystal build $(CRFLAGS) src/tcpc.cr -o 'tcpc'
@ -50,7 +56,7 @@ tcpc.uninstall:
@echo ' RM > $(BINDIR)/tcpc' @echo ' RM > $(BINDIR)/tcpc'
$(Q)rm -f '$(DESTDIR)$(BINDIR)/tcpc' $(Q)rm -f '$(DESTDIR)$(BINDIR)/tcpc'
pongd: src/pongd.cr pongd: src/pongd.cr
@echo ' CR > pongd' @echo ' CR > pongd'
$(Q)crystal build $(CRFLAGS) src/pongd.cr -o 'pongd' $(Q)crystal build $(CRFLAGS) src/pongd.cr -o 'pongd'
@ -68,7 +74,7 @@ pongd.uninstall:
@echo ' RM > $(BINDIR)/pongd' @echo ' RM > $(BINDIR)/pongd'
$(Q)rm -f '$(DESTDIR)$(BINDIR)/pongd' $(Q)rm -f '$(DESTDIR)$(BINDIR)/pongd'
pongc: src/pongc.cr pongc: src/pongc.cr
@echo ' CR > pongc' @echo ' CR > pongc'
$(Q)crystal build $(CRFLAGS) src/pongc.cr -o 'pongc' $(Q)crystal build $(CRFLAGS) src/pongc.cr -o 'pongc'
@ -86,25 +92,25 @@ pongc.uninstall:
@echo ' RM > $(BINDIR)/pongc' @echo ' RM > $(BINDIR)/pongc'
$(Q)rm -f '$(DESTDIR)$(BINDIR)/pongc' $(Q)rm -f '$(DESTDIR)$(BINDIR)/pongc'
plumberd: src/plumberd.cr ipcd: src/ipcd.cr
@echo ' CR > plumberd' @echo ' CR > ipcd'
$(Q)crystal build $(CRFLAGS) src/plumberd.cr -o 'plumberd' $(Q)crystal build $(CRFLAGS) src/ipcd.cr -o 'ipcd'
plumberd.install: plumberd ipcd.install: ipcd
@echo ' IN > $(BINDIR)/plumberd' @echo ' IN > $(BINDIR)/ipcd'
$(Q)mkdir -p '$(DESTDIR)$(BINDIR)' $(Q)mkdir -p '$(DESTDIR)$(BINDIR)'
$(Q)install -m0755 plumberd $(DESTDIR)$(BINDIR)/plumberd $(Q)install -m0755 ipcd $(DESTDIR)$(BINDIR)/ipcd
plumberd.clean: ipcd.clean:
@echo ' RM > plumberd' @echo ' RM > ipcd'
$(Q)rm -f plumberd $(Q)rm -f ipcd
plumberd.uninstall: ipcd.uninstall:
@echo ' RM > $(BINDIR)/plumberd' @echo ' RM > $(BINDIR)/ipcd'
$(Q)rm -f '$(DESTDIR)$(BINDIR)/plumberd' $(Q)rm -f '$(DESTDIR)$(BINDIR)/ipcd'
websocketc: src/websocketc.cr websocketc: src/websocketc.cr
@echo ' CR > websocketc' @echo ' CR > websocketc'
$(Q)crystal build $(CRFLAGS) src/websocketc.cr -o 'websocketc' $(Q)crystal build $(CRFLAGS) src/websocketc.cr -o 'websocketc'
@ -122,7 +128,7 @@ websocketc.uninstall:
@echo ' RM > $(BINDIR)/websocketc' @echo ' RM > $(BINDIR)/websocketc'
$(Q)rm -f '$(DESTDIR)$(BINDIR)/websocketc' $(Q)rm -f '$(DESTDIR)$(BINDIR)/websocketc'
websocketd: src/websocketd.cr websocketd: src/websocketd.cr
@echo ' CR > websocketd' @echo ' CR > websocketd'
$(Q)crystal build $(CRFLAGS) src/websocketd.cr -o 'websocketd' $(Q)crystal build $(CRFLAGS) src/websocketd.cr -o 'websocketd'
@ -158,13 +164,13 @@ $(DESTDIR)$(INCLUDEDIR):
$(DESTDIR)$(MANDIR): $(DESTDIR)$(MANDIR):
@echo ' DIR > $(MANDIR)' @echo ' DIR > $(MANDIR)'
$(Q)mkdir -p $(DESTDIR)$(MANDIR) $(Q)mkdir -p $(DESTDIR)$(MANDIR)
install: tcpd.install tcpc.install pongd.install pongc.install plumberd.install websocketc.install websocketd.install install: tcpd.install tcpc.install pongd.install pongc.install ipcd.install websocketc.install websocketd.install
@: @:
uninstall: tcpd.uninstall tcpc.uninstall pongd.uninstall pongc.uninstall plumberd.uninstall websocketc.uninstall websocketd.uninstall uninstall: tcpd.uninstall tcpc.uninstall pongd.uninstall pongc.uninstall ipcd.uninstall websocketc.uninstall websocketd.uninstall
@: @:
clean: tcpd.clean tcpc.clean pongd.clean pongc.clean plumberd.clean websocketc.clean websocketd.clean clean: tcpd.clean tcpc.clean pongd.clean pongc.clean ipcd.clean websocketc.clean websocketd.clean
distclean: clean distclean: clean
dist: dist-gz dist-xz dist-bz2 dist: dist-gz dist-xz dist-bz2
$(Q)rm -- $(PACKAGE)-$(VERSION) $(Q)rm -- $(PACKAGE)-$(VERSION)
@ -182,8 +188,8 @@ $(PACKAGE)-$(VERSION).tar.gz: distdir
$(PACKAGE)-$(VERSION)/src/tcpc.cr \ $(PACKAGE)-$(VERSION)/src/tcpc.cr \
$(PACKAGE)-$(VERSION)/src/pongc.cr \ $(PACKAGE)-$(VERSION)/src/pongc.cr \
$(PACKAGE)-$(VERSION)/src/tcpd.cr \ $(PACKAGE)-$(VERSION)/src/tcpd.cr \
$(PACKAGE)-$(VERSION)/src/plumberd.cr \ $(PACKAGE)-$(VERSION)/src/pongd.cr \
$(PACKAGE)-$(VERSION)/src/pongd.cr $(PACKAGE)-$(VERSION)/src/ipcd.cr
dist-xz: $(PACKAGE)-$(VERSION).tar.xz dist-xz: $(PACKAGE)-$(VERSION).tar.xz
$(PACKAGE)-$(VERSION).tar.xz: distdir $(PACKAGE)-$(VERSION).tar.xz: distdir
@ -194,8 +200,8 @@ $(PACKAGE)-$(VERSION).tar.xz: distdir
$(PACKAGE)-$(VERSION)/src/tcpc.cr \ $(PACKAGE)-$(VERSION)/src/tcpc.cr \
$(PACKAGE)-$(VERSION)/src/pongc.cr \ $(PACKAGE)-$(VERSION)/src/pongc.cr \
$(PACKAGE)-$(VERSION)/src/tcpd.cr \ $(PACKAGE)-$(VERSION)/src/tcpd.cr \
$(PACKAGE)-$(VERSION)/src/plumberd.cr \ $(PACKAGE)-$(VERSION)/src/pongd.cr \
$(PACKAGE)-$(VERSION)/src/pongd.cr $(PACKAGE)-$(VERSION)/src/ipcd.cr
dist-bz2: $(PACKAGE)-$(VERSION).tar.bz2 dist-bz2: $(PACKAGE)-$(VERSION).tar.bz2
$(PACKAGE)-$(VERSION).tar.bz2: distdir $(PACKAGE)-$(VERSION).tar.bz2: distdir
@ -206,11 +212,11 @@ $(PACKAGE)-$(VERSION).tar.bz2: distdir
$(PACKAGE)-$(VERSION)/src/tcpc.cr \ $(PACKAGE)-$(VERSION)/src/tcpc.cr \
$(PACKAGE)-$(VERSION)/src/pongc.cr \ $(PACKAGE)-$(VERSION)/src/pongc.cr \
$(PACKAGE)-$(VERSION)/src/tcpd.cr \ $(PACKAGE)-$(VERSION)/src/tcpd.cr \
$(PACKAGE)-$(VERSION)/src/plumberd.cr \ $(PACKAGE)-$(VERSION)/src/pongd.cr \
$(PACKAGE)-$(VERSION)/src/pongd.cr $(PACKAGE)-$(VERSION)/src/ipcd.cr
help: help:
@echo ' :: plumberd-0.1.0' @echo ' :: ipcd-0.2.1'
@echo '' @echo ''
@echo 'Generic targets:' @echo 'Generic targets:'
@echo ' - help  Prints this help message.' @echo ' - help  Prints this help message.'
@ -240,7 +246,7 @@ help:
@echo ' - tcpc  crystal' @echo ' - tcpc  crystal'
@echo ' - pongd  crystal' @echo ' - pongd  crystal'
@echo ' - pongc  crystal' @echo ' - pongc  crystal'
@echo ' - plumberd  crystal' @echo ' - ipcd  crystal'
@echo ' - websocketc  crystal' @echo ' - websocketc  crystal'
@echo ' - websocketd  crystal' @echo ' - websocketd  crystal'
@echo '' @echo ''

View File

@ -1,6 +1,6 @@
package=ipcd package=ipcd
version=0.2.0 version=0.2.1
targets=(tcpd tcpc pongd pongc ipcd websocketc websocketd) targets=(tcpd tcpc pongd pongc ipcd websocketc websocketd)

View File

@ -86,8 +86,8 @@ class HTTP::WebSocket
@current_message.write @buffer[0, info.size] @current_message.write @buffer[0, info.size]
if info.final if info.final
message = @current_message.to_s message = @current_message.to_s
@on_close.try &.call(message) @on_close.try &.call(HTTP::WebSocket::CloseCode::NormalClosure, message)
close(message) unless closed? close(HTTP::WebSocket::CloseCode::NormalClosure, message) unless closed?
@current_message.clear @current_message.clear
return Close.new return Close.new
end end