The OpenD Programming Language

WebSocket.onclose

The CloseEvent you get references a temporary buffer that may be overwritten after your handler returns. If you want to keep it or the event.reason member, remember to .idup it.

class WebSocket
arsd.core.FlexibleDelegate!(void delegate(CloseEvent event)) onclose;

Meta

History

The CloseEvent was changed to a arsd.core.FlexibleDelegate on March 19, 2023 (dub v11.0). Before that, onclose was a public member of type void delegate(). This change means setters still work with or without the CloseEvent argument.

Your onclose method is now also called on abnormal terminations. Check the wasClean member of the CloseEvent to know if it came from a close frame or other cause.