From fdb32f2dfd92725f849fdd3f4477135cd20f9164 Mon Sep 17 00:00:00 2001 From: "Mahlon E. Smith" Date: Wed, 27 Oct 2021 14:36:25 -0700 Subject: [PATCH] Updates for more modern (v1.6.0) nim. --- Makefile | 4 ++-- README.md | 3 +-- src/stomp.nim | 24 +++++++++--------------- stomp.nimble | 2 +- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index ac3bc11..be86066 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ CACHE = .cache default: development development: ${FILES} - nim --debugInfo --assertions:on --linedir:on -d:ssl --define:debug --nimcache:${CACHE} c ${FILES} + nim --debugInfo --assertions:on --profiler:on --stackTrace:on --linedir:on -d:ssl --define:debug --nimcache:${CACHE} c ${FILES} @mv src/stomp . autobuild: @@ -16,7 +16,7 @@ debugger: ${FILES} nim --debugger:on --nimcache:${CACHE} c ${FILES} release: ${FILES} - nim -d:release --opt:speed --nimcache:${CACHE} c ${FILES} + nim -d:release --opt:speed --panics:on --nimcache:${CACHE} c ${FILES} @mv src/stomp . docs: diff --git a/README.md b/README.md index 18f70db..c1d2973 100644 --- a/README.md +++ b/README.md @@ -153,8 +153,7 @@ This is a complete client that does the following: # (This should be compiled with -d:ssl) import - json, - net, + std/[net,json], stomp let diff --git a/src/stomp.nim b/src/stomp.nim index ae3831c..0b44f8b 100644 --- a/src/stomp.nim +++ b/src/stomp.nim @@ -50,12 +50,12 @@ ## import - strutils, - nativesockets, - net, - os, - times, - uri + std/nativesockets, + std/net, + std/os, + std/strutils, + std/times, + std/uri const VERSION = "0.1.3" ## The current program version. @@ -130,7 +130,7 @@ proc parse_headers( response: StompResponse, c: StompClient ): int = c.socket.readline( line, c.timeout ) while not line.is_eol: - if defined( debug ): printf " <-- %s\n", line + if defined( debug ): printf " <-- %s\n", cstring(line) var header = line.split( ":" ) if header.len < 2: break response.headers.add( (header[0], header[1]) ) @@ -206,7 +206,7 @@ proc newStompResponse( c: StompClient ): StompResponse = # result.frame = line if defined( debug ): - printf " <-- %s\n", line + printf " <-- %s\n", cstring(line) # Parse headers and body. # @@ -319,7 +319,7 @@ proc newStompClient*( s: Socket, uri: string ): StompClient = result.options.heartbeat = opt[1].parse_int else: discard - except IndexError, ValueError: + except IndexDefect, ValueError: discard # Set default STOMP port if otherwise unset. @@ -763,12 +763,6 @@ need to URI escape: /%2Ftest proc receive_message( c: StompClient, r: StompResponse ) = messages.add( r ) - case r.frame: - of "RECEIPT": - discard - of "MESSAGE": - discard r.payload - discard r[ "ack" ] proc seen_heartbeat( c: StompClient, r: StompResponse ) = heartbeats = heartbeats + 1 diff --git a/stomp.nimble b/stomp.nimble index 2b81c08..2c99d30 100644 --- a/stomp.nimble +++ b/stomp.nimble @@ -11,5 +11,5 @@ srcDir = "src" # Dependencies -requires "nim >= 0.19.0" +requires "nim >= 1.4.0"