Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
131
Issues
131
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-gargantext
Commits
739f2d62
Verified
Commit
739f2d62
authored
Jun 21, 2024
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[websockets] correctly pick ws/wss protocol based on window.location
parent
557c4dc5
Pipeline
#6258
failed with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
6 deletions
+22
-6
App.purs
src/Gargantext/Components/App/App.purs
+2
-1
Notifications.purs
src/Gargantext/Components/Notifications.purs
+12
-0
Utils.purs
src/Gargantext/Utils.purs
+8
-5
No files found.
src/Gargantext/Components/App/App.purs
View file @
739f2d62
...
...
@@ -106,7 +106,8 @@ mainAppCpt = here.component "main" cpt where
(Sessions.Sessions { sessions }) <- T.read boxes.sessions
let session = Seq.head sessions
-- here.log2 "[mainApp] sessions" sessions'
Notifications.connect ws "ws://localhost:8008/ws" session
wsProto <- Notifications.wsProtocol
Notifications.connect ws (wsProto <> "://localhost:8008/ws") session
-- T.write_ ws boxes.wsNotification
-- NOTE: Dummy subscription
-- let action = NotificationsT.InsertCallback (NotificationsT.UpdateTree (-1)) "some-uuid" (\_ -> here.log "callback!")
...
...
src/Gargantext/Components/Notifications.purs
View file @
739f2d62
...
...
@@ -21,6 +21,7 @@ import Foreign as F
import Gargantext.Components.Notifications.Types
import Gargantext.Sessions.Types (Session(..))
import Gargantext.Types as GT
import Gargantext.Utils (protocol)
import Gargantext.Utils.Reactix as R2
import Prelude
import Reactix as R
...
...
@@ -143,6 +144,17 @@ performAction (WSNotification ws') (Call notification) = do
callNotification state notification
-- | Correctly choose between "ws" and "wss" protocols based on what
-- | is the current window location
wsProtocol :: Effect String
wsProtocol = do
proto <- protocol
pure (if proto == "http" then "ws" else "wss")
-- | Main WebSockets connect functionality. Handles incoming messages,
-- | authorizes user (if logged in), tries to reconnect when the
-- | connection drops
connect :: WSNotification -> String -> (Maybe Session) -> Effect Unit
connect ws@(WSNotification ws') url session = do
mConn <- Ref.read ws'.connection
...
...
src/Gargantext/Utils.purs
View file @
739f2d62
...
...
@@ -17,7 +17,7 @@ import Partial.Unsafe (unsafePartial)
import Prelude
import Web.HTML as WHTML
import Web.HTML.Location as WHL
import Web.HTML.Window
(location)
import Web.HTML.Window
as WHW
-- | TODO (hard coded)
csrfMiddlewareToken :: String
...
...
@@ -103,11 +103,14 @@ sortWith :: forall a b f. Functor f =>
sortWith f xs = A.toUnfoldable $ A.sortWith f (A.fromFoldable xs)
location :: Effect WHL.Location
location = WHTML.window >>= WHW.location
href :: Effect String
href =
do
w <- WHTML.window
loc <- location w
WHL.href loc
href =
location >>= WHL.href
protocol :: Effect String
protocol = location >>= WHL.protocol
nbsp :: Int -> String
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment