websockets

package
v0.0.0-...-2031ce5 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: AGPL-3.0, AGPL-3.0-or-later Imports: 21 Imported by: 0

Documentation

Overview

Package websockets manages active websocket connections and messages received from and sent to them

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePost

func CreatePost(req PostCreationRequest, op uint64) (
	post db.Post, msg []byte, err error,
)

CreatePost creates a new post and writes it to the database.

func CreateThread

func CreateThread(req ThreadCreationRequest) (
	post db.Post, err error,
)

CreateThread creates a new thread and writes it to the database.

func Handler

func Handler(w http.ResponseWriter, r *http.Request)

Handler is an http.HandleFunc that responds to new websocket connection requests.

Types

type Client

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

Client stores and manages a websocket-connected remote client and its interaction with the server and database

func (*Client) Close

func (c *Client) Close(err error)

Close closes a websocket connection with the provided status code and optional reason

func (*Client) IP

func (c *Client) IP() string

IP returns the IP of the client connection. Thread-safe, as the IP is never written to after assignment.

func (*Client) Redirect

func (c *Client) Redirect(board string)

Redirect closes any open posts and forces the client to sync to the target board

func (*Client) Send

func (c *Client) Send(msg []byte)

Send a message to the client. Can be used concurrently.

type FilesRequest

type FilesRequest struct {
	Tokens []string
}

type PostCreationRequest

type PostCreationRequest struct {
	FilesRequest FilesRequest
	Board        string
	Ip           string
	Body         string
	Token        string
	Sign         string
	ShowBadge    bool
	ShowName     bool
	Session      *auth.Session
}

PostCreationRequest contains common fields for both thread and post creation.

type ThreadCreationRequest

type ThreadCreationRequest struct {
	PostCreationRequest
	Subject string
}

ThreadCreationRequest contains data for creating a new thread.

Jump to

Keyboard shortcuts

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