From ee4f328031c8072868854ebcd5a1e5b628a226ae Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 2 May 2017 22:45:58 -0400 Subject: allow building with versions in debian When built with old websockets, compression is not supported. Client and server will negotiate that so version skew between them is not a problem. --- WebSockets.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'WebSockets.hs') diff --git a/WebSockets.hs b/WebSockets.hs index a220c68..359fe7b 100644 --- a/WebSockets.hs +++ b/WebSockets.hs @@ -5,6 +5,7 @@ {-# LANGUAGE OverloadedStrings, DeriveGeneric, GeneralizedNewtypeDeriving #-} {-# LANGUAGE FlexibleContexts, FlexibleInstances, ScopedTypeVariables #-} +{-# LANGUAGE CPP #-} module WebSockets ( connectionOptions, @@ -91,7 +92,9 @@ instance WebSocketsData WireProtocol where WireProtocolError (Data.Aeson.decode s) _ -> WireProtocolError "received unknown websocket message" +#if MIN_VERSION_websockets(0,10,0) fromDataMessage = fromLazyByteString . fromDataMessage +#endif -- | Modes of operation that can be requested for a websocket connection. data Mode @@ -113,12 +116,14 @@ instance ToJSON WireVersion supportedWireVersions :: [WireVersion] supportedWireVersions = [WireVersion "1"] --- | Enable compression. connectionOptions :: ConnectionOptions connectionOptions = defaultConnectionOptions +#if MIN_VERSION_websockets(0,10,0) + -- Enable compression. { connectionCompressionOptions = PermessageDeflateCompression defaultPermessageDeflate } +#endif -- For some reason, runClient throws ConnectionClosed -- when the server hangs up cleanly. Catch this unwanted exception. -- cgit v1.2.3