go-socket.io icon indicating copy to clipboard operation
go-socket.io copied to clipboard

Remove panic from source code

Open sshaplygin opened this issue 6 years ago • 4 comments

sshaplygin avatar Nov 27 '19 21:11 sshaplygin

I don't think removing panic is reasonable. It's useful when parsing/unparsing.

googollee avatar Dec 04 '19 21:12 googollee

I know to it. Panic use only in handler.go file. At now, we use f interface{} at parameter at newEventFunc and newAckFunc i think it is not best way. Because user caught panic at runtime. We may use new type HandlerFunc as gin-gonic way, because we used four signature at OnEvent in practice func(s socketio.Conn, msg string), func(s socketio.Conn, msg string) string, func(s socketio.Conn) string. I suggest all callback use as func (c socketio.Context). Remaining handlers similar callback at OnEvent handlers.

But we need refactor all source code to integrate my suggest. It theme linked with this issue

Panic code:

sshaplygin avatar Dec 05 '19 20:12 sshaplygin

That's fine. So the feature is to make a register function with a context instead of interface{}, but not remove panic.

I think to making another issue and giving some background would be better.

googollee avatar Dec 09 '19 09:12 googollee

Or, shall we dup this to #275?

googollee avatar Dec 09 '19 09:12 googollee