[ws] remove explicit ping/pong messages

parent e27f6a18
......@@ -58,8 +58,6 @@ data WSRequest =
| WSUnsubscribe Topic
| WSAuthorize String
| WSDeauthorize
| WSPing
| WSPong
derive instance Generic WSRequest _
instance Eq WSRequest where eq = genericEq
instance JSON.WriteForeign WSRequest where
......@@ -70,14 +68,10 @@ instance JSON.WriteForeign WSRequest where
writeImpl (WSAuthorize token) = JSON.writeImpl { request: "authorize"
, token }
writeImpl WSDeauthorize = JSON.writeImpl { request: "deauthorize" }
writeImpl WSPing = JSON.writeImpl "ping"
writeImpl WSPong = JSON.writeImpl "pong"
data Notification =
Notification Topic
| Ping
| Pong
derive instance Generic Notification _
instance Eq Notification where eq = genericEq
instance JSON.ReadForeign Notification where
......@@ -87,8 +81,6 @@ instance JSON.ReadForeign Notification where
Nothing -> do
{ notification: topic } <- JSON.readImpl f :: F.F { notification :: Topic }
pure $ Notification topic
Just "ping" -> pure Ping
Just "pong" -> pure Pong
Just s -> F.fail $ F.ErrorAtProperty "_" $ F.ForeignError $ "unkown string: " <> s
......@@ -243,17 +235,15 @@ connect (WSNotification ws') url session = do
s <- runExceptT $ F.readString (ME.data_ me)
case s of
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
let parsed = JSON.readJSON s' :: JSON.E Notification
case parsed of
Left err -> do
here.log2 "[connect] I can't parse message" err
here.log2 "[connect] Can't parse message" err
Right (Notification topic) -> do
here.log2 "[connect] notification" topic
performAction ws (Call topic)
-- pings are quiet
Right Ping -> pure unit
Right parsed' -> do
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