Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FE: Websockets now automatically reconnect if there's a network dropout.
- Loading branch information
1 parent
9f539af
commit 1f787f7
Showing
19 changed files
with
345 additions
and
118 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,30 @@ | ||
module Main where | ||
|
||
import Prelude | ||
import Control.Coroutine (connect, runProcess) | ||
import Control.Coroutine.Extra (mapConsumer) | ||
import Effect (Effect) | ||
import Effect.Aff (Aff, forkAff) | ||
import Effect.Unsafe (unsafePerformEffect) | ||
import Halogen.Aff (awaitBody, runHalogenAff) | ||
import Halogen.VDom.Driver (runUI) | ||
import MainFrame (initialMainFrame) | ||
import Plutus.SCB.Webserver.Types (StreamToClient) | ||
import Types (HAction(..), Output(..), Query(..)) | ||
import WebSocket.Support (mkSocket, Output) as WS | ||
import WebSocket.Support (wsConsumer, wsProducer, wsSender) | ||
import Plutus.SCB.Webserver.Types (StreamToClient, StreamToServer) | ||
import Types (HAction(..), Query(..)) | ||
import WebSocket.Support (WebSocketManager, mkWebSocketManager) | ||
import WebSocket.Support as WS | ||
|
||
main :: Effect Unit | ||
main = do | ||
socket <- WS.mkSocket "/ws" | ||
runHalogenAff do | ||
body <- awaitBody | ||
driver <- runUI initialMainFrame Init body | ||
let | ||
handleWebSocket :: WS.Output StreamToClient -> Aff Unit | ||
handleWebSocket msg = void $ driver.query $ ReceiveWebSocketMessage msg unit | ||
void $ forkAff | ||
$ runProcess | ||
$ connect | ||
(wsProducer socket) | ||
(wsConsumer handleWebSocket) | ||
driver.subscribe | ||
$ mapConsumer (case _ of (SendWebSocketMessage msg) -> msg) | ||
$ wsSender handleWebSocket socket | ||
wsManager :: WebSocketManager StreamToClient StreamToServer <- | ||
mkWebSocketManager | ||
void | ||
$ forkAff | ||
$ WS.runWebSocketManager | ||
(WS.URI "/ws") | ||
(\msg -> void $ driver.query $ ReceiveWebSocketMessage msg unit) | ||
wsManager | ||
|
||
onLoad :: Unit | ||
onLoad = unsafePerformEffect main |
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.