Documentation
¶
Index ¶
- func ErrorToHttpCode(err error) int
- func SendJsonResponse(writer http.ResponseWriter, resp interface{}, err error)
- func WSConnJSONReaderWriter(conn *websocket.Conn) (reader *conc.Reader[gut.StringMap], ...)
- func WSConnWriteError(wsConn *websocket.Conn, err error) error
- func WSConnWriteMessage(wsConn *websocket.Conn, msg interface{}) error
- func WSHandleConn[I any, S WSConn[I]](conn *websocket.Conn, ctx S, config *WSConnConfig)
- func WSServe[I any, S WSConn[I]](h WSHandler[I, S], config *WSConnConfig) http.HandlerFunc
- type BiDirStreamConfig
- type BiDirStreamConn
- type JSONConn
- func (j *JSONConn) ConnId() string
- func (j *JSONConn) DebugInfo() any
- func (j *JSONConn) HandleMessage(msg any) error
- func (j *JSONConn) Name() string
- func (j *JSONConn) OnClose()
- func (j *JSONConn) OnError(err error) error
- func (j *JSONConn) OnStart(conn *websocket.Conn) error
- func (j *JSONConn) OnTimeout() bool
- func (j *JSONConn) ReadMessage(conn *websocket.Conn) (out any, err error)
- func (j *JSONConn) SendPing() error
- type JSONHandler
- type WSConn
- type WSConnConfig
- type WSHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorToHttpCode ¶
func SendJsonResponse ¶
func SendJsonResponse(writer http.ResponseWriter, resp interface{}, err error)
func WSConnJSONReaderWriter ¶ added in v0.0.59
func WSConnWriteMessage ¶
func WSHandleConn ¶ added in v0.0.60
func WSHandleConn[I any, S WSConn[I]](conn *websocket.Conn, ctx S, config *WSConnConfig)
func WSServe ¶ added in v0.0.60
func WSServe[I any, S WSConn[I]](h WSHandler[I, S], config *WSConnConfig) http.HandlerFunc
Types ¶
type BiDirStreamConfig ¶ added in v0.0.70
func DefaultBiDirStreamConfig ¶ added in v0.0.70
func DefaultBiDirStreamConfig() *BiDirStreamConfig
type BiDirStreamConn ¶ added in v0.0.70
type BiDirStreamConn[I any] interface { /** * Called to send the next ping message. */ SendPing() error // Optional Name of the connection Name() string // Optional connection id ConnId() string /** * Called to handle the next message from the input stream on the ws conn. */ HandleMessage(msg I) error /** * Called to handle or suppress an error */ OnError(err error) error /** * Called when the connection closes. */ OnClose() OnTimeout() bool }
type JSONConn ¶ added in v0.0.62
type JSONConn struct { Writer *conc.Writer[conc.Message[any]] NameStr string ConnIdStr string PingId int64 }
func (*JSONConn) HandleMessage ¶ added in v0.0.62
*
- Called to handle the next message from the input stream on the ws conn.
func (*JSONConn) OnClose ¶ added in v0.0.62
func (j *JSONConn) OnClose()
*
- Called when the connection closes.
type JSONHandler ¶ added in v0.0.60
type JSONHandler struct { }
func (*JSONHandler) Validate ¶ added in v0.0.60
func (j *JSONHandler) Validate(w http.ResponseWriter, r *http.Request) (out WSConn[any], isValid bool)
type WSConnConfig ¶ added in v0.0.60
type WSConnConfig struct { *BiDirStreamConfig Upgrader websocket.Upgrader }
func DefaultWSConnConfig ¶ added in v0.0.60
func DefaultWSConnConfig() *WSConnConfig
Click to show internal directories.
Click to hide internal directories.