go-socket.io
go-socket.io copied to clipboard
Raw proposal for go-socket.io v2
Is your feature request related to a problem? Please describe. Current libs version doesn't supported socket.io v2
It is not completed proposal version. I suggest some changes. At the future this document will be edit
API:
-
Change create new server object
Current version
server := socketio.NewServer(nil)
New version client code
server := socketio.New()
inner code
// New create go-socket.io server instance func New(opts ...Options) *Server { ... }
-
Hide
server.Serve()
andserver.Close()
methodCurrent version
go server.Serve() defer server.Close()
New version
//empty
-
Change adapter interface
Current version
ok, err := server.Adapter(&socketio.RedisAdapterOptions if err != nil { log.Println("error:", err) return
New version client code
err := server.Adapter() if err != nil { log.Println("error:", err) return
inner code
func (s *Server) Adapter(opts ...AdapterOptions) (error) { ... }
Inner changes:
- Add level mode for full server logs
-
NewServer()
As I still want to have client code, NewServer()
is more clear that it returns a server, and NewClient()
returns a client.
-
Serve()
andClose()
Serve()
gives a preparing period before a server working.
s := gio.NewServer()
// Prepare before the server working
go s.Serve()
Another we could keep that function, and make new creators like LaunchServer()
which calls Serve()
before returning.
I also hope to keep Close()
to have a graceful way to quit a server. If someone wants a server running forever, they could ignore calling this function.
- Adaptor
I have more thoughts about the adaptor. I hope to support middleware to let adaptor hook messages, and no need to limit adaptor as Redis or other queue implementation.
I agree with @googollee here. I prefer to have the option to close a connection and choose to prepare the server, than to hide it inside the library. It's a bit more verbose but in this case I'd say it's a good thing
I think it's possible to remove Serve()
function, by redesign engine.io. I'd like to do that in the new version and to see if it's possible to down-merge the new version to the old one. (If API doesn't change too much.)
If API doesn't change too much.
Why not? It is good changelog for new version ))
In this implementation run go-socket,io server without Server()
and Close()
method
Another we could keep that function, and make new creators like LaunchServer() which calls Serve() before returning.
I also hope to keep Close() to have a graceful way to quit a server. If someone wants a server running forever, they could ignore calling this function.
It is good decision by my opinion.
Currently engine.io
wraps a connection as a sock and that's why socket.io needs a Serve()
to start a goroutine to do the "listen" thing.
As it requires changing the design of engine.io, I hope to remove Serve()
and Close()
in the next version. Also, I don't think breaking API in this version is good for users.
Why not?
I suggest add debug mode into socket.io and egnine.io level. What are you thins about this idea?
For the engineio design in v3-dev, as it provides hooks for all kind of messages, I tend to not add log in engineio.
No idea for socketio new design yet.
I suggest update new major version in socketio with changes cleaner public API. i think it changes is worthy new major version. I think, current API does not implement full functionality original API by js version socketio
Hey, @ralfbawg! If you havta some ideas by public API or some deep things realisation in new second major version, please, tell to us.
Does this mean the corresponding server version is only 1.x ? here
Current version of socket.io is 4.4.1. Does this library works only with 1.x which is 6 years old?
@Mistic92 yes, this project needs help
@erkie How can i contribute? I would love to contribute
There is a telegram channel, and there are a bunch of issues here in github. Just pick one and get going!