jaspervdj / websockets-snap

Snap integration for the websockets library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to exit runWebSocketSnap

henrylaxen opened this issue · comments

Please excuse me if this is a dumb question, but I can't seem to
figure out how to return from a runWebSocketSnap app. In my code I
have something like:

runWebSocketsSnap (\pending -> do
    sink <- acceptRequest pending
    .. do some stuff ..
    liftIO $ putStrLn "Got here 1"
  )
  liftIO $ putStrLn "Got here 2"

I print out "Got here 1", but never "Got here 2"

How do I get out of runWebSocketsSnap and return to the caller?
Any insight would be appreciated.

Best wishes,
Henry Laxen

I'm not sure what you want to do. If you explain what you want to do exactly, I might be able to help more.

You pass runWebSocketsSnap a handler which assumes control by upgrading an HTTP connection to a WebSockets connection. However, it's not possible to downgrade a WebSockets connection to an HTTP connection.

Dear Jasper,

Yes, I finally realized this. I wanted to do some clean up after I was done
with the websocket app, which would have been in the IO monad, but now I'm
just doing it as part of the app itself, and not the Snap backend that called
it.

Thanks for taking the time to reply.
Best wishes,
Henry Laxen

Jasper Van der Jeugt writes:

I'm not sure what you want to do. If you explain what you want to do exactly,
I might be able to help more.

You pass runWebSocketsSnap a handler which assumes control by upgrading an
HTTP connection to a WebSockets connection. However, it's not possible to
downgrade a WebSockets connection to an HTTP connection.


Reply to this email directly or view it on GitHub.*

Nadine and Henry Laxen The rest is silence
Villa Alta #6
Calle Gaviota #10 Never try to teach a pig to sing
Chapala It wastes your time
(376) 765-3181 And it annoys the pig

                         ;\ 
                        |' \ 
     _                  ; : ; 
    / `-.              /: : | 
   |  ,-.`-.          ,': : | 
   \  :  `. `.       ,'-. : | 
    \ ;    ;  `-.__,'    `-.| 
     \ ;   ;  :::  ,::'`:.  `. 
      \ `-. :  `    :.    `.  \ 
       \   \    ,   ;   ,:    (\ 
        \   :., :.    ,'o)): ` `-. 
       ,/,' ;' ,::"'`.`---'   `.  `-._ 
     ,/  :  ; '"      `;'          ,--`. 
    ;/   :; ;             ,:'     (   ,:) 
      ,.,:.    ; ,:.,  ,-._ `.     \""'/ 
      '::'     `:'`  ,'(  \`._____.-'"' 
         ;,   ;  `.  `. `._`-.  \\ 
         ;:.  ;:       `-._`-.\  \`. 
          '`:. :        |' `. `\  ) \ 
             ` ;:       |    `--\__,' 
               '`      ,' 
                    ,-'