feeds

package
v0.0.0-...-1a9902f Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: AGPL-3.0, AGPL-3.0-or-later Imports: 6 Imported by: 0

Documentation

Overview

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.

Index

Constants

View Source
const TickerInterval = time.Millisecond * 100

TickerInterval sets the interval of ticker flushes

Variables

This section is empty.

Functions

func All

func All() []common.Client

All returns all currently connected clients

func Clear

func Clear()

Clear removes all existing feeds and clients. Used only in tests.

func ClosePost

func ClosePost(id, op uint64, links []common.Link, commands []common.Command,
) (err error)

ClosePost closes a post in a feed, if it exists

func GetByIP

func GetByIP(ip string) []common.Client

GetByIP returns all clients matching the specified IP

func GetByIPAndBoard

func GetByIPAndBoard(ip, board string) []common.Client

GetByIPAndBoard retrieves all Clients that match the passed IP on a board

func GetByThread

func GetByThread(id uint64) []common.Client

GetByThread gets all synced to a thread

func GetSync

func GetSync(cl common.Client) (synced bool, op uint64, board string)

GetSync returns if the client is synced and the thread and board it is synced to

func IPCount

func IPCount() int

IPCount returns number of unique connected IPs

func Init

func Init() (err error)

Initialize internal runtime

func InsertPostInto

func InsertPostInto(post common.StandalonePost, msg []byte)

InsertPostInto inserts a post into a tread feed, if it exists. Only use for already closed posts.

func RegisterIP

func RegisterIP(ip string) (err error)

Regiter IP as conencted

func RemoveClient

func RemoveClient(cl common.Client)

RemoveClient removes a client from the global client map and any subscribed to feed

func SendTo

func SendTo(id uint64, msg []byte)

SendTo sends a message to a feed, if it exists

func SubscribeToMeguTV

func SubscribeToMeguTV(c common.Client) (err error)

SubscribeToMeguTV subscribes to random video stream. Clients are automatically unsubscribed, when leaving their current sync feed.

func UnregisterIP

func UnregisterIP(ip string)

Unregister IP as conencted

Types

type Feed

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

Feed is a feed with synchronization logic of a certain thread

func SyncClient

func SyncClient(cl common.Client, op uint64, board string) (*Feed, error)

SyncClient adds a client to a the global client map and synchronizes to an update feed, if any. If the client was already synced to another feed, it is automatically unsubscribed.

func (*Feed) ClosePost

func (f *Feed) ClosePost(id uint64, msg []byte)

ClosePost closes a feed's post

func (*Feed) InsertImage

func (f *Feed) InsertImage(id uint64, spoilered bool, msg []byte)

InsertImage inserts an image into an already allocated post

func (*Feed) InsertPost

func (f *Feed) InsertPost(p common.Post, msg []byte)

InsertPost inserts a new post into the thread or reclaim an open post after disconnect and propagate to listeners

func (*Feed) Send

func (f *Feed) Send(msg []byte)

Send a message to all listening clients

func (*Feed) SetOpenBody

func (f *Feed) SetOpenBody(id uint64, body string, msg []byte)

SetOpenBody sets the body of an open post and send update message to clients

func (*Feed) SpoilerImage

func (f *Feed) SpoilerImage(id uint64, msg []byte)

SpoilerImage spoilers a feed's image

func (*Feed) Start

func (f *Feed) Start() (err error)

Start read existing posts into cache and start main loop

Jump to

Keyboard shortcuts

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