Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
XHR Polling is now basically working, what remains to be done are pro…
…per response headers, decode incoming JSON, more importantly add timeouts and heartbeats, but most importatnly -- make the code prettier (adding a Server monad containing environment, settings, Request wrapper containing (Maybe) Application, Session, SessionID, etc. might help a bit, but there are some disgustingly long lines in Transports.XHR)
- Loading branch information
Showing
11 changed files
with
185 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Data.ByteString.Extra | ||
( convertBS2BL | ||
, convertBL2BS | ||
, convertTS2BL | ||
) where | ||
|
||
------------------------------------------------------------------------------ | ||
import qualified Data.ByteString.Lazy as BL (ByteString, toChunks, fromChunks) | ||
import qualified Data.ByteString as BS (ByteString, concat) | ||
import qualified Data.Text as TS (Text) | ||
import qualified Data.Text.Encoding as TS (encodeUtf8) | ||
------------------------------------------------------------------------------ | ||
|
||
convertBS2BL :: BS.ByteString -> BL.ByteString | ||
convertBS2BL = BL.fromChunks . (:[]) | ||
|
||
convertBL2BS :: BL.ByteString -> BS.ByteString | ||
convertBL2BS = BS.concat . BL.toChunks | ||
|
||
convertTS2BL :: TS.Text -> BL.ByteString | ||
convertTS2BL = convertBS2BL . TS.encodeUtf8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
module Network.Wai.Sock | ||
( | ||
( Application(..) | ||
, ApplicationSettings(..) | ||
, ServerSettings(..) | ||
, Environment(..) | ||
, sock | ||
) where | ||
|
||
import Network.Wai.Sock.Internal.Types | ||
import Network.Wai.Sock.Handler | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
{-# LANGUAGE RecordWildCards #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
|
||
module Network.Wai.Sock.Application | ||
( Application(..) | ||
, ApplicationSettings(..) | ||
, runApplication | ||
) where | ||
|
||
------------------------------------------------------------------------------ | ||
import Network.Wai.Sock.Internal.Types (Application(..), ApplicationSettings(..)) | ||
import Control.Monad.IO.Class | ||
import Control.Monad.Trans.Control | ||
------------------------------------------------------------------------------ | ||
import qualified Data.Conduit as C | ||
import qualified Data.Conduit.TMChan as C (sourceTMChan, sinkTMChan) | ||
------------------------------------------------------------------------------ | ||
import Network.Wai.Sock.Internal.Types (Application(..), ApplicationSettings(..), Session(..)) | ||
------------------------------------------------------------------------------ | ||
|
||
runApplication :: (MonadBaseControl IO m, MonadIO m) | ||
=> Application m | ||
-> Session | ||
-> m () | ||
runApplication Application{..} Session{..} = | ||
applicationDefinition (C.sourceTMChan sessionIncomingBuffer) | ||
(C.sinkTMChan sessionOutgoingBuffer) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.