{"@context":"https://w3id.org/codemeta/3.0","@type":"SoftwareSourceCode","identifier":"pkg:golang/github.com/2lambda123/websocket","name":"github.com/2lambda123/websocket","description":"Package websocket implements the WebSocket protocol defined in RFC 6455.\n\nThe Conn type represents a WebSocket connection. A server application calls\nthe Upgrader.Upgrade method from an HTTP request handler to get a *Conn:\n\nCall the connection's WriteMessage and ReadMessage methods to send and\nreceive messages as a slice of bytes. This snippet of code shows how to echo\nmessages using these methods:\n\nIn above snippet of code, p is a []byte and messageType is an int with value\nwebsocket.BinaryMessage or websocket.TextMessage.\n\nAn application can also send and receive messages using the io.WriteCloser\nand io.Reader interfaces. To send a message, call the connection NextWriter\nmethod to get an io.WriteCloser, write the message to the writer and close\nthe writer when done. To receive a message, call the connection NextReader\nmethod to get an io.Reader and read until io.EOF is returned. This snippet\nshows how to echo messages using the NextWriter and NextReader methods:\n\nThe WebSocket protocol distinguishes between text and binary data messages.\nText messages are interpreted as UTF-8 encoded text. The interpretation of\nbinary messages is left to the application.\n\nThis package uses the TextMessage and BinaryMessage integer constants to\nidentify the two data message types. The ReadMessage and NextReader methods\nreturn the type of the received message. The messageType argument to the\nWriteMessage and NextWriter methods specifies the type of a sent message.\n\nIt is the application's responsibility to ensure that text messages are\nvalid UTF-8 encoded text.\n\nThe WebSocket protocol defines three types of control messages: close, ping\nand pong. Call the connection WriteControl, WriteMessage or NextWriter\nmethods to send a control message to the peer.\n\nConnections handle received close messages by calling the handler function\nset with the SetCloseHandler method and by returning a *CloseError from the\nNextReader, ReadMessage or the message Read method. The default close\nhandler sends a close message to the peer.\n\nConnections handle received ping messages by calling the handler function\nset with the SetPingHandler method. The default ping handler sends a pong\nmessage to the peer.\n\nConnections handle received pong messages by calling the handler function\nset with the SetPongHandler method. The default pong handler does nothing.\nIf an application sends ping messages, then the application should set a\npong handler to receive the corresponding pong.\n\nThe control message handler functions are called from the NextReader,\nReadMessage and message reader Read methods. The default close and ping\nhandlers can block these methods for a short time when the handler writes to\nthe connection.\n\nThe application must read the connection to process close, ping and pong\nmessages sent from the peer. If the application is not otherwise interested\nin messages from the peer, then the application should start a goroutine to\nread and discard messages from the peer. A simple example is:\n\nConnections support one concurrent reader and one concurrent writer.\n\nApplications are responsible for ensuring that no more than one goroutine\ncalls the write methods (NextWriter, SetWriteDeadline, WriteMessage,\nWriteJSON, EnableWriteCompression, SetCompressionLevel) concurrently and\nthat no more than one goroutine calls the read methods (NextReader,\nSetReadDeadline, ReadMessage, ReadJSON, SetPongHandler, SetPingHandler)\nconcurrently.\n\nThe Close and WriteControl methods can be called concurrently with all other\nmethods.\n\nWeb browsers allow Javascript applications to open a WebSocket connection to\nany host. It's up to the server to enforce an origin policy using the Origin\nrequest header sent by the browser.\n\nThe Upgrader calls the function specified in the CheckOrigin field to check\nthe origin. If the CheckOrigin function returns false, then the Upgrade\nmethod fails the WebSocket handshake with HTTP status 403.\n\nIf the CheckOrigin field is nil, then the Upgrader uses a safe default: fail\nthe handshake if the Origin request header is present and the Origin host is\nnot equal to the Host request header.\n\nThe deprecated package-level Upgrade function does not perform origin\nchecking. The application is responsible for checking the Origin header\nbefore calling the Upgrade function.\n\nPer message compression extensions (RFC 7692) are experimentally supported\nby this package in a limited capacity. Setting the EnableCompression option\nto true in Dialer or Upgrader will attempt to negotiate per message deflate\nsupport.\n\nIf compression was successfully negotiated with the connection's peer, any\nmessage received in compressed form will be automatically decompressed.\nAll Read methods will return uncompressed bytes.\n\nPer message compression of messages written to a connection can be enabled\nor disabled by calling the corresponding Conn method:\n\nCurrently this package does not support compression with \"context takeover\".\nThis means that messages must be compressed and decompressed in isolation,\nwithout retaining sliding window or dictionary state across messages. For\nmore details refer to RFC 7692.\n\nUse of compression is experimental and may result in decreased performance.","version":"v1.5.1","softwareVersion":"v1.5.1","license":"https://spdx.org/licenses/BSD-2-Clause","codeRepository":"https://github.com/2lambda123/websocket","issueTracker":"https://github.com/2lambda123/websocket/issues","url":"https://github.com/2lambda123/websocket","programmingLanguage":{"@type":"ComputerLanguage","name":"Go"},"dateCreated":"2016-04-28","dateModified":"2023-10-18","datePublished":"2023-10-18","copyrightYear":2016,"downloadUrl":"https://proxy.golang.org/github.com/2lambda123/websocket/@v/v1.5.1.zip","softwareHelp":{"@type":"WebSite","url":"https://pkg.go.dev/github.com/2lambda123/websocket#section-documentation"},"applicationCategory":"go","runtimePlatform":"go","developmentStatus":"active","sameAs":["https://pkg.go.dev/github.com/2lambda123/websocket"]}