mailbox

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package mailbox provides asynchronous message delivery to players. A mailbox is registered with the Player's UID using the Add function which returns a channel for receiving messages. Messages can be sent using the Send function with the UID of the recipient player. When the mailbox is no longer required Delete should be called to close the channel and remove the mailbox.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(uid string) <-chan string

Add a mailbox for the given UID and return a channel for receiving mailbox messages.

func Delete

func Delete(uid string)

Delete removes the mailbox for the given UID. Any messages send to a deleted mailbox will be discarded. Outstanding messages not retrieved yet will still be delivered.

func Exists

func Exists(uid string) bool

Exists returns true if a mailbox exists for the UID, otherwise false.

func Len

func Len() (l int)

Len returns the number of mailboxes currently in use.

func Send

func Send(uid string, priority bool, msg string)

Send writes the given message to the mailbox for the given UID. Priority messages are always sent. Non-priority messages are sent if they are not a repeat of the last non-priority message sent - this helps cut down on message spamming. If mailbox is full then remove + drop oldest message and try adding message again.

Types

This section is empty.

Jump to

Keyboard shortcuts

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