github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/gorilla/websocket/README.md (about)

     1  # Gorilla WebSocket
     2  
     3  Gorilla WebSocket is a [Go](http://golang.org/) implementation of the
     4  [WebSocket](http://www.rfc-editor.org/rfc/rfc6455.txt) protocol.
     5  
     6  ### Documentation
     7  
     8  * [API Reference](http://godoc.org/github.com/gorilla/websocket)
     9  * [Chat example](https://github.com/gorilla/websocket/tree/master/examples/chat)
    10  * [Command example](https://github.com/gorilla/websocket/tree/master/examples/command)
    11  * [Client and server example](https://github.com/gorilla/websocket/tree/master/examples/echo)
    12  * [File watch example](https://github.com/gorilla/websocket/tree/master/examples/filewatch)
    13  
    14  ### Status
    15  
    16  The Gorilla WebSocket package provides a complete and tested implementation of
    17  the [WebSocket](http://www.rfc-editor.org/rfc/rfc6455.txt) protocol. The
    18  package API is stable.
    19  
    20  ### Installation
    21  
    22      go get github.com/gorilla/websocket
    23  
    24  ### Protocol Compliance
    25  
    26  The Gorilla WebSocket package passes the server tests in the [Autobahn Test
    27  Suite](http://autobahn.ws/testsuite) using the application in the [examples/autobahn
    28  subdirectory](https://github.com/gorilla/websocket/tree/master/examples/autobahn).
    29  
    30  ### Gorilla WebSocket compared with other packages
    31  
    32  <table>
    33  <tr>
    34  <th></th>
    35  <th><a href="http://godoc.org/github.com/gorilla/websocket">github.com/gorilla</a></th>
    36  <th><a href="http://godoc.org/golang.org/x/net/websocket">golang.org/x/net</a></th>
    37  </tr>
    38  <tr>
    39  <tr><td colspan="3"><a href="http://tools.ietf.org/html/rfc6455">RFC 6455</a> Features</td></tr>
    40  <tr><td>Passes <a href="http://autobahn.ws/testsuite/">Autobahn Test Suite</a></td><td><a href="https://github.com/gorilla/websocket/tree/master/examples/autobahn">Yes</a></td><td>No</td></tr>
    41  <tr><td>Receive <a href="https://tools.ietf.org/html/rfc6455#section-5.4">fragmented</a> message<td>Yes</td><td><a href="https://code.google.com/p/go/issues/detail?id=7632">No</a>, see note 1</td></tr>
    42  <tr><td>Send <a href="https://tools.ietf.org/html/rfc6455#section-5.5.1">close</a> message</td><td><a href="http://godoc.org/github.com/gorilla/websocket#hdr-Control_Messages">Yes</a></td><td><a href="https://code.google.com/p/go/issues/detail?id=4588">No</a></td></tr>
    43  <tr><td>Send <a href="https://tools.ietf.org/html/rfc6455#section-5.5.2">pings</a> and receive <a href="https://tools.ietf.org/html/rfc6455#section-5.5.3">pongs</a></td><td><a href="http://godoc.org/github.com/gorilla/websocket#hdr-Control_Messages">Yes</a></td><td>No</td></tr>
    44  <tr><td>Get the <a href="https://tools.ietf.org/html/rfc6455#section-5.6">type</a> of a received data message</td><td>Yes</td><td>Yes, see note 2</td></tr>
    45  <tr><td colspan="3">Other Features</tr></td>
    46  <tr><td>Limit size of received message</td><td><a href="http://godoc.org/github.com/gorilla/websocket#Conn.SetReadLimit">Yes</a></td><td><a href="https://code.google.com/p/go/issues/detail?id=5082">No</a></td></tr>
    47  <tr><td>Read message using io.Reader</td><td><a href="http://godoc.org/github.com/gorilla/websocket#Conn.NextReader">Yes</a></td><td>No, see note 3</td></tr>
    48  <tr><td>Write message using io.WriteCloser</td><td><a href="http://godoc.org/github.com/gorilla/websocket#Conn.NextWriter">Yes</a></td><td>No, see note 3</td></tr>
    49  </table>
    50  
    51  Notes: 
    52  
    53  1. Large messages are fragmented in [Chrome's new WebSocket implementation](http://www.ietf.org/mail-archive/web/hybi/current/msg10503.html).
    54  2. The application can get the type of a received data message by implementing
    55     a [Codec marshal](http://godoc.org/golang.org/x/net/websocket#Codec.Marshal)
    56     function.
    57  3. The go.net io.Reader and io.Writer operate across WebSocket frame boundaries.
    58    Read returns when the input buffer is full or a frame boundary is
    59    encountered. Each call to Write sends a single frame message. The Gorilla
    60    io.Reader and io.WriteCloser operate on a single WebSocket message.
    61