Documentation
¶
Overview ¶
Package binarysocket is a real-time bidirectional binary socket library for the web. It offers a clean, robust and efficient way to connect webbrowsers with a go-backend in a simple way. It automatically detects supported socket layers and chooses the most suitable one. This library offers a net.Conn interface on the go-backend site and a similar net.Conn interface on the client javascript site. That's awesome, right? You already have a Go application using a TCP connection? Just drop in the BinarySocket package, fire up a HTTP server and that's it. No further adaptions are required in the backend. Instead of writing one backend which is responsible to communicate with web-application and another backend which communicates with other go programs, BinarySocket eliminates this duplication.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClosed defines the error if the connection was closed. ErrClosed = errors.New("closed") )
var ( // Log is the public logrus value used internally. Log = logrus.New() )
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// ReadBufferSize and WriteBufferSize specify I/O buffer sizes. If a buffer
// size is zero, then a default value of 4096 is used. The I/O buffer sizes
// do not limit the size of the messages that can be sent or received.
ReadBufferSize, WriteBufferSize int
// CheckOrigin returns true if the request Origin header is acceptable. If
// CheckOrigin is nil, the host in the Origin header must not be set or
// must match the host of the request.
// This method is used by the backend sockets before establishing connections.
CheckOrigin func(r *http.Request) bool
// DisableAjax deactivates the ajax backend.
DisableAjax bool
}
Options define the BinarySocket optional options.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements the web server which handles the websocket and ajax connections.
func (*Server) Accept ¶
Accept waits for the next client socket connection and returns a generic Conn. Returns ErrClosed if the server is closed.
func (*Server) Close ¶
Close the server by blocking all new incoming connections. This does not close the http server.