Hi Sven,

Maybe you missed the additional post with the source code (I attached it
again below with small change in way it is logging). Is there any advice on
how to do this (other than the workaround I'm using at the moment)? The
issue being that the client recognises its own closing only after a timeout
(around 30 seconds by default). A message "Client closed" will appear on the
Transcript after this 30 seconds. With the workaround (see comment in code),
it does recognise the closing immediately.

As you can see, I'm already using #runWith: as you suggested. Your recent
addition of sending 'ping' does not change the synchronous behaviour.

I'm using this on a Pharo 7 image, but also tested it on Pharo 9.

Kind regards,
Erik

Just in case, I added the code again (without using #crLog: this time):

| server client | 
server := ZnWebSocket startServerOn: 1701 do: [ :webSocket | 
        [ webSocket runWith: [ :message | Transcript show: 'Received
message: ', message 
printString ; cr ] ] 
        on: ConnectionClosed, PrimitiveFailed do: [ "ignore close" ]. 
        Transcript show: 'The server is closed' ; cr ]. 
client := ZnWebSocket to: (ZnUrl fromString: 'ws://localhost:1701'). 
[ 
        [ client runWith: [ :message | "ignore received messages" ] ] 
        on: ConnectionClosed, PrimitiveFailed do: [ "ignore close" ]. 
        Transcript show: 'The client is closed' ; cr. 
        server stop ] fork. 
(Delay forSeconds: 1) wait. 
client sendMessage: 'Hello world'. 
client close. 
"Workaround: use the following instead of 'client close'. 
client sendFrame: ZnWebSocketFrame close." 





--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

Reply via email to