websockets

package
v4.4.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2017 License: AGPL-3.0, AGPL-3.0-or-later Imports: 20 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(
	op uint64,
	board, ip string,
	needCaptcha bool,
	req ReplyCreationRequest,
) (
	post db.Post, msg []byte, err error,
)

CreatePost creates a new post and writes it to the database. open specifies, if the post should stay open after creation.

func CreateThread

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

CreateThread creates a new tread and writes it to the database. open specifies, if the thread OP should stay open after creation.

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 ImageRequest

type ImageRequest struct {
	Spoiler     bool
	Token, Name string
}

ImageRequest contains data for allocating an image

type ReplyCreationRequest

type ReplyCreationRequest struct {
	Sage, Open bool
	Image      ImageRequest
	auth.SessionCreds
	auth.Captcha
	Name, Password, Body string
}

ReplyCreationRequest contains common fields for both thread and reply creation

type ThreadCreationRequest

type ThreadCreationRequest struct {
	NonLive bool
	ReplyCreationRequest
	Subject, Board string
}

ThreadCreationRequest contains data for creating a new thread

Directories

Path Synopsis
Package feeds manages client synchronization to update feeds and provides a thread-safe interface for propagating messages to them and reassigning feeds to and from clients.
Package feeds manages client synchronization to update feeds and provides a thread-safe interface for propagating messages to them and reassigning feeds to and from clients.

Jump to

Keyboard shortcuts

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