Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net/websocket: No way to manage connection outside of handler #5959

Open
lukescott opened this issue Jul 25, 2013 · 4 comments

Comments

@lukescott
Copy link

commented Jul 25, 2013

Currently there is no way to get a websocket.Conn object without leaving the handler, or
without having a handler at all. I need to wrap the websocket.Conn object for another
library, but not without maintaing a blocked go routine.

I suggest adding this method:

func (s Server) Upgrade(w http.ResponseWriter, req *http.Request) (conn *Conn, err
error) {
    var rwc net.Conn
    var buf *bufio.ReadWriter
    if rwc, buf, err = w.(http.Hijacker).Hijack(); err != nil {
        return nil, err
    }
    conn, err = newServerConn(rwc, buf, req, &s.Config, s.Handshake);
    return
}
@robpike

This comment has been minimized.

Copy link
Contributor

commented Aug 4, 2013

Comment 1:

Labels changed: added priority-later, removed priority-triage.

Status changed to Accepted.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Nov 27, 2013

Comment 2:

Labels changed: added go1.3maybe.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Dec 4, 2013

Comment 3:

Labels changed: added release-none, removed go1.3maybe.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Dec 4, 2013

Comment 4:

Labels changed: added repo-net.

@mikioh mikioh changed the title go.net/websocket: No way to manage connection outside of handler x/net/websocket: No way to manage connection outside of handler Dec 23, 2014

@mikioh mikioh added repo-net and removed repo-net labels Dec 23, 2014

@mikioh mikioh changed the title x/net/websocket: No way to manage connection outside of handler websocket: No way to manage connection outside of handler Jan 4, 2015

@rsc rsc added this to the Unplanned milestone Apr 10, 2015

@rsc rsc changed the title websocket: No way to manage connection outside of handler x/net/websocket: No way to manage connection outside of handler Apr 14, 2015

@rsc rsc modified the milestones: Unreleased, Unplanned Apr 14, 2015

@rsc rsc removed the repo-net label Apr 14, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.