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

View File

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

View File

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