Commit e81d7210 authored by Russ Cox's avatar Russ Cox

websocket: rename websocket.WebSocketAddr to *websocket.Addr.

R=ukai
CC=golang-dev
https://golang.org/cl/4999043
parent 33d00fae
...@@ -57,13 +57,13 @@ var ( ...@@ -57,13 +57,13 @@ var (
ErrNotSupported = ProtocolError{"not supported"} ErrNotSupported = ProtocolError{"not supported"}
) )
// WebSocketAddr is an implementation of net.Addr for WebSocket. // Addr is an implementation of net.Addr for WebSocket.
type WebSocketAddr struct { type Addr struct {
*url.URL *url.URL
} }
// Network returns the network type for a WebSocket, "websocket". // Network returns the network type for a WebSocket, "websocket".
func (addr WebSocketAddr) Network() string { return "websocket" } func (addr *Addr) Network() string { return "websocket" }
// Config is a WebSocket configuration // Config is a WebSocket configuration
type Config struct { type Config struct {
...@@ -219,18 +219,18 @@ func (ws *Conn) IsServerConn() bool { return ws.request != nil } ...@@ -219,18 +219,18 @@ func (ws *Conn) IsServerConn() bool { return ws.request != nil }
// the WebSocket location for server. // the WebSocket location for server.
func (ws *Conn) LocalAddr() net.Addr { func (ws *Conn) LocalAddr() net.Addr {
if ws.IsClientConn() { if ws.IsClientConn() {
return WebSocketAddr{ws.config.Origin} return &Addr{ws.config.Origin}
} }
return WebSocketAddr{ws.config.Location} return &Addr{ws.config.Location}
} }
// RemoteAddr returns the WebSocket location for the connection for client, or // RemoteAddr returns the WebSocket location for the connection for client, or
// the Websocket Origin for server. // the Websocket Origin for server.
func (ws *Conn) RemoteAddr() net.Addr { func (ws *Conn) RemoteAddr() net.Addr {
if ws.IsClientConn() { if ws.IsClientConn() {
return WebSocketAddr{ws.config.Location} return &Addr{ws.config.Location}
} }
return WebSocketAddr{ws.config.Origin} return &Addr{ws.config.Origin}
} }
// SetTimeout sets the connection's network timeout in nanoseconds. // SetTimeout sets the connection's network timeout in nanoseconds.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment