live

package
v0.0.0-...-ae8ac80 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2022 License: MPL-2.0 Imports: 9 Imported by: 0

README

Realtime Communications

This package implements the functionality needed to support realtime chat operations. This happens over a websocket connection that is initiated on the /live endpoint. An example client that connects and displays chat messages in realtime is provided in the `/demoLiveClient directory.

Known Limitations

  • Sending messages from the live client WIP
  • Restricted to a single connection per user. In the real world this would need to support multiple connections from the same user.

TODO

  • Unit testing

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoSuchClientErr = errors.New("no such client is connected")

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func Open

func Open(server *Server, user database.User, serverCtx context.Context, w http.ResponseWriter, r *http.Request, onDisconnect ClientFunc) (*Client, error)

func (*Client) Close

func (client *Client) Close()

func (*Client) SendMessage

func (client *Client) SendMessage(message database.Message) error

type ClientFunc

type ClientFunc func(client *Client) error

type Server

type Server struct {
	// contains filtered or unexported fields
}

func Create

func Create(db *database.Database) *Server

func (*Server) RunWithClient

func (server *Server) RunWithClient(userUUID uuid.UUID, clientFunc ClientFunc) error

RunWithClient - Runs a function with a connected client protected by the client mutex

func (*Server) ServeWebsocket

func (server *Server) ServeWebsocket(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL