This repository was archived by the owner on Sep 29, 2024. It is now read-only.

Description
After PR #274 i propose add new wrappers types similar as gin-gonic's types. It will be more comfortable and user friendly
New types propose will named as HandlerFunc and Context
Need implement on HandlerFunc next function interfaces:
- onConnect:
func(c Conn) error
- onError:
func(c Conn, err error)
- onDisconnect:
func(c Conn, msg string)
- Event:
func(c Conn, msg string) string / func(c Conn, msg string)
I propose to refactor OnConnect method to union interface func(c Conn) without returned error to func(c Conn, err error)
Context will be contain:
connect Conn,
message string
err error
Feature usage example:
func OnConnectMainHandler () socketio.HandlerFunc {
//NOTICE: add some middleware logic
return func(context *socketio.Context) {
context.connect.SetContext("")
fmt.Println("connected:", s.ID())
return nil
}
}
// Add to server OnConnect event
server.OnConnect("/", OnConnectIndexHandler());