[ws] remove explicit ping/pong messages

parent e27f6a18
Pipeline #6176 failed with stages
in 2 minutes and 46 seconds
...@@ -58,8 +58,6 @@ data WSRequest = ...@@ -58,8 +58,6 @@ data WSRequest =
| WSUnsubscribe Topic | WSUnsubscribe Topic
| WSAuthorize String | WSAuthorize String
| WSDeauthorize | WSDeauthorize
| WSPing
| WSPong
derive instance Generic WSRequest _ derive instance Generic WSRequest _
instance Eq WSRequest where eq = genericEq instance Eq WSRequest where eq = genericEq
instance JSON.WriteForeign WSRequest where instance JSON.WriteForeign WSRequest where
...@@ -70,14 +68,10 @@ instance JSON.WriteForeign WSRequest where ...@@ -70,14 +68,10 @@ instance JSON.WriteForeign WSRequest where
writeImpl (WSAuthorize token) = JSON.writeImpl { request: "authorize" writeImpl (WSAuthorize token) = JSON.writeImpl { request: "authorize"
, token } , token }
writeImpl WSDeauthorize = JSON.writeImpl { request: "deauthorize" } writeImpl WSDeauthorize = JSON.writeImpl { request: "deauthorize" }
writeImpl WSPing = JSON.writeImpl "ping"
writeImpl WSPong = JSON.writeImpl "pong"
data Notification = data Notification =
Notification Topic Notification Topic
| Ping
| Pong
derive instance Generic Notification _ derive instance Generic Notification _
instance Eq Notification where eq = genericEq instance Eq Notification where eq = genericEq
instance JSON.ReadForeign Notification where instance JSON.ReadForeign Notification where
...@@ -87,8 +81,6 @@ instance JSON.ReadForeign Notification where ...@@ -87,8 +81,6 @@ instance JSON.ReadForeign Notification where
Nothing -> do Nothing -> do
{ notification: topic } <- JSON.readImpl f :: F.F { notification :: Topic } { notification: topic } <- JSON.readImpl f :: F.F { notification :: Topic }
pure $ Notification topic pure $ Notification topic
Just "ping" -> pure Ping
Just "pong" -> pure Pong
Just s -> F.fail $ F.ErrorAtProperty "_" $ F.ForeignError $ "unkown string: " <> s Just s -> F.fail $ F.ErrorAtProperty "_" $ F.ForeignError $ "unkown string: " <> s
...@@ -243,17 +235,15 @@ connect (WSNotification ws') url session = do ...@@ -243,17 +235,15 @@ connect (WSNotification ws') url session = do
s <- runExceptT $ F.readString (ME.data_ me) s <- runExceptT $ F.readString (ME.data_ me)
case s of case s of
Left err -> do Left err -> do
here.log2 "[connect] data received is not a string - I was expecting a JSON string!" err here.log2 "[connect] data received is not a string - was expecting a JSON string!" err
Right s' -> do Right s' -> do
let parsed = JSON.readJSON s' :: JSON.E Notification let parsed = JSON.readJSON s' :: JSON.E Notification
case parsed of case parsed of
Left err -> do Left err -> do
here.log2 "[connect] I can't parse message" err here.log2 "[connect] Can't parse message" err
Right (Notification topic) -> do Right (Notification topic) -> do
here.log2 "[connect] notification" topic here.log2 "[connect] notification" topic
performAction ws (Call topic) performAction ws (Call topic)
-- pings are quiet
Right Ping -> pure unit
Right parsed' -> do Right parsed' -> do
here.log2 "[connect] onmessage, F.readString" parsed' here.log2 "[connect] onmessage, F.readString" parsed'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment