~haskell-guy/ssb-haskell

dd39bdc8c23734f35fbf3bc3250ee3ff03724772 — Haskell Guy 4 months ago 7e6e3e3
Fix Room hosting

 - Use the correct RPC handler for when the 'host-room' command is used.
 - Avoid making clients hang up by returning OK when the rpc endpoint
   call is unknown.
2 files changed, 4 insertions(+), 2 deletions(-)

M app/Main.hs
M src/Ssb/Peer/RPC/Room.hs
M app/Main.hs => app/Main.hs +1 -1
@@ 109,7 109,7 @@ hostRoomCMD name desc hostname = do
        Room.Invite { host = hostname, port = "8008", key = publicKey me }
  putStrLn $ "Hosting room for '" <> Room.formatInvite roomInvite <> "'"

  router <- defaultHandler
  router <- Room.newRoom name desc
  TCP.serveRPC router hostname (Room.port roomInvite) mainNet me

parser :: Options.Parser Command

M src/Ssb/Peer/RPC/Room.hs => src/Ssb/Peer/RPC/Room.hs +3 -1
@@ 315,7 315,9 @@ instance RPC.Handler Room where
    resp <- getCurrentTime
    RPC.writeStreamJSON stream resp

  serve room endpoint@otherwise arg stream = (RPC.notFoundHandlerFunc endpoint) arg stream
  -- HACK: return OK when endpoint not known to avoid disconnecting clients
  serve room endpoint@otherwise arg stream = return . return ()
  --serve room endpoint@otherwise arg stream = (RPC.notFoundHandlerFunc endpoint) arg stream

  notifyConnect _ _ = return . return $ ()