diff options
| author | Ondřej Surý <ondrej@sury.org> | 2011-10-06 09:35:45 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2011-10-06 09:35:45 +0200 |
| commit | 6c7ca6e4d4e26e4c8cbe0d183966011b3b088a0a (patch) | |
| tree | fddeb87db026d64a1d8e597dd0c69d685f433597 /src/pkg/websocket/websocket.go | |
| parent | 04f99b387021a8ce32a8795360cba9beaf986a81 (diff) | |
| download | golang-6c7ca6e4d4e26e4c8cbe0d183966011b3b088a0a.tar.gz | |
Imported Upstream version 2011.09.21upstream-weekly/2011.09.21
Diffstat (limited to 'src/pkg/websocket/websocket.go')
| -rw-r--r-- | src/pkg/websocket/websocket.go | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/pkg/websocket/websocket.go b/src/pkg/websocket/websocket.go index 1d063c31f..d57d1149c 100644 --- a/src/pkg/websocket/websocket.go +++ b/src/pkg/websocket/websocket.go @@ -57,16 +57,13 @@ var ( ErrNotSupported = ProtocolError{"not supported"} ) -// WebSocketAddr is an implementation of net.Addr for WebSocket. -type WebSocketAddr struct { +// Addr is an implementation of net.Addr for WebSocket. +type Addr struct { *url.URL } // Network returns the network type for a WebSocket, "websocket". -func (addr WebSocketAddr) Network() string { return "websocket" } - -// String returns the network address for a WebSocket. -func (addr WebSocketAddr) String() string { return addr.String() } +func (addr *Addr) Network() string { return "websocket" } // Config is a WebSocket configuration type Config struct { @@ -222,18 +219,18 @@ func (ws *Conn) IsServerConn() bool { return ws.request != nil } // the WebSocket location for server. func (ws *Conn) LocalAddr() net.Addr { 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 // the Websocket Origin for server. func (ws *Conn) RemoteAddr() net.Addr { 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. |
