chat

package
v0.27.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MaxPreviousMessageCount = 5
View Source
const (
	MaxServerBoundMessageLength = 256
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgumentSignature

type ArgumentSignature struct {
	Name      string
	Signature []byte
}

func (*ArgumentSignature) Decode

func (a *ArgumentSignature) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*ArgumentSignature) Encode

func (a *ArgumentSignature) Encode(c *proto.PacketContext, wr io.Writer) error

type ArgumentSignatures

type ArgumentSignatures struct {
	Entries []ArgumentSignature
}

func (*ArgumentSignatures) Decode

func (*ArgumentSignatures) Encode

type Builder

type Builder struct {
	// Protocol is the protocol version of the message.
	// If not set, defaults to supporting older clients.
	Protocol proto.Protocol
	// Component is the component to send to the client.
	// If nil, Message is used instead.
	Component component.Component
	Message   string // Only used if Component is nil
	// Type is the position the message is going to be sent.
	// If not set, defaults to ChatMessageType.
	Type MessageType
	// Sender is the UUID of the player who sent the message.
	// If zero (uuid.Nil), the message is sent by the server.
	Sender uuid.UUID
	// Timestamp is the time the message was sent.
	Timestamp time.Time
}

Builder is a builder for chat packets.

func (*Builder) ToClient

func (b *Builder) ToClient() proto.Packet

ToClient creates a packet which can be sent to the client; using the provided information in the builder.

func (*Builder) ToServer

func (b *Builder) ToServer() proto.Packet

ToServer creates a packet which can be sent to the server; using the provided information in the builder.

type KeyedPlayerChat

type KeyedPlayerChat struct {
	Message          string
	SignedPreview    bool
	Unsigned         bool
	Expiry           time.Time // may be zero if no salt or signature specified
	Signature        []byte
	Salt             []byte
	PreviousMessages []*crypto.SignaturePair
	LastMessage      *crypto.SignaturePair
}

func (*KeyedPlayerChat) Decode

func (p *KeyedPlayerChat) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*KeyedPlayerChat) Encode

func (p *KeyedPlayerChat) Encode(c *proto.PacketContext, wr io.Writer) error

type KeyedPlayerCommand

type KeyedPlayerCommand struct {
	Unsigned         bool
	Command          string
	Timestamp        time.Time
	Salt             int64
	SignedPreview    bool // purely for pass through for 1.19 -> 1.19.2 - this will never be implemented
	Arguments        map[string][]byte
	PreviousMessages []*crypto.SignaturePair
	LastMessage      *crypto.SignaturePair
}

func NewKeyedPlayerCommand

func NewKeyedPlayerCommand(command string, arguments []string, timestamp time.Time) *KeyedPlayerCommand

NewKeyedPlayerCommand returns a new KeyedPlayerCommand packet based on a command and list of arguments.

func (*KeyedPlayerCommand) Decode

func (p *KeyedPlayerCommand) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*KeyedPlayerCommand) Encode

type LastSeenMessages

type LastSeenMessages struct {
	Offset       int
	Acknowledged mathutil.BitSet
}

func (*LastSeenMessages) Decode

func (l *LastSeenMessages) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*LastSeenMessages) Empty

func (l *LastSeenMessages) Empty() bool

func (*LastSeenMessages) Encode

func (l *LastSeenMessages) Encode(c *proto.PacketContext, wr io.Writer) error

type LegacyChat

type LegacyChat struct {
	Message string
	Type    MessageType
	Sender  uuid.UUID // 1.16+, and can be empty UUID, all zeros
}

func (*LegacyChat) Decode

func (ch *LegacyChat) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*LegacyChat) Encode

func (ch *LegacyChat) Encode(c *proto.PacketContext, wr io.Writer) error

type MessageType

type MessageType byte

MessageType is the position a chat message is going to be sent.

const (
	// ChatMessageType lets the chat message appear in the client's HUD.
	// These messages can be filtered out by the client's settings.
	ChatMessageType MessageType = iota
	// SystemMessageType lets the chat message appear in the client's HUD and can't be dismissed.
	SystemMessageType
	// GameInfoMessageType lets the chat message appear above the player's main HUD.
	// This text format doesn't support many component features, such as hover events.
	GameInfoMessageType
)

type RemoteChatSession

type RemoteChatSession struct {
	ID  uuid.UUID // may be zero
	Key crypto.IdentifiedKey
}

RemoteChatSession represents a remote chat session that is used to send messages.

func (*RemoteChatSession) Decode

func (r *RemoteChatSession) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*RemoteChatSession) Encode

func (r *RemoteChatSession) Encode(c *proto.PacketContext, wr io.Writer) error

func (*RemoteChatSession) IdentifiedKey

func (r *RemoteChatSession) IdentifiedKey() crypto.IdentifiedKey

func (*RemoteChatSession) SessionID

func (r *RemoteChatSession) SessionID() uuid.UUID

type SessionPlayerChat

type SessionPlayerChat struct {
	Message          string
	Timestamp        time.Time
	Salt             int64
	Signed           bool
	Signature        []byte
	LastSeenMessages LastSeenMessages
}

func (*SessionPlayerChat) Decode

func (p *SessionPlayerChat) Decode(c *proto.PacketContext, rd io.Reader) error

func (*SessionPlayerChat) Encode

func (p *SessionPlayerChat) Encode(c *proto.PacketContext, wr io.Writer) error

type SessionPlayerCommand

type SessionPlayerCommand struct {
	Command            string
	Timestamp          time.Time
	Salt               int64
	ArgumentSignatures ArgumentSignatures
	LastSeenMessages   LastSeenMessages
}

func (*SessionPlayerCommand) Decode

func (*SessionPlayerCommand) Encode

func (*SessionPlayerCommand) Signed

func (s *SessionPlayerCommand) Signed() bool

type SystemChat

type SystemChat struct {
	Component component.Component
	Type      MessageType
}

func (*SystemChat) Decode

func (p *SystemChat) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*SystemChat) Encode

func (p *SystemChat) Encode(c *proto.PacketContext, wr io.Writer) error

Jump to

Keyboard shortcuts

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