Documentation
¶
Index ¶
- Constants
- func CreateEmoteMessage(playerID, playerName, action string) *message.Message
- func CreateSayMessage(playerID, playerName, text string) *message.Message
- func CreateShoutMessage(playerID, playerName, text string) *message.Message
- func CreateTellMessage(senderID, senderName, targetID, targetName, text string) *message.Message
- func FormatCommunicationMessage(msg *message.Message) (string, error)
- type Channel
- type CommunicationBuilder
- func (b *CommunicationBuilder) Build() *message.Message
- func (b *CommunicationBuilder) FromPlayer(playerID, playerName string) *CommunicationBuilder
- func (b *CommunicationBuilder) InRoom(worldID, roomID string) *CommunicationBuilder
- func (b *CommunicationBuilder) RequireAck(timeout time.Duration) *CommunicationBuilder
- func (b *CommunicationBuilder) ToPlayer(playerID, playerName string) *CommunicationBuilder
- func (b *CommunicationBuilder) WithText(text string) *CommunicationBuilder
- func (b *CommunicationBuilder) WithTimestamp(timestamp time.Time) *CommunicationBuilder
- type CommunicationData
- type CommunicationManager
- func (cm *CommunicationManager) CreateChannel(id, name, channelType string) *Channel
- func (cm *CommunicationManager) FilterMessage(msg *message.Message, recipientID string) (*message.Message, error)
- func (cm *CommunicationManager) GetChannel(id string) (*Channel, bool)
- func (cm *CommunicationManager) GetChannelMembers(channelID string) []string
- func (cm *CommunicationManager) GetMessageHistory(contextType, contextID string, limit int) ([]*message.Message, error)
- func (cm *CommunicationManager) GetPlayerLocation(playerID string) (PlayerLocation, bool)
- func (cm *CommunicationManager) GetPlayersInRoom(worldID, roomID string) []string
- func (cm *CommunicationManager) GetPlayersInWorld(worldID string) []string
- func (cm *CommunicationManager) HandleMessage(msg *message.Message, senderID string) error
- func (cm *CommunicationManager) JoinChannel(channelID, playerID string) error
- func (cm *CommunicationManager) LeaveChannel(channelID, playerID string) error
- func (cm *CommunicationManager) RegisterMessageHandler(messageType int64, handler func(*message.Message, string) error)
- func (cm *CommunicationManager) RemovePlayerLocation(playerID string)
- func (cm *CommunicationManager) SendToChannel(channelID string, msg *message.Message) error
- func (cm *CommunicationManager) SendToPlayer(playerID string, msg *message.Message) error
- func (cm *CommunicationManager) SendToRoom(worldID, roomID string, msg *message.Message) error
- func (cm *CommunicationManager) SendToWorld(worldID string, msg *message.Message) error
- func (cm *CommunicationManager) UpdatePlayerLocation(playerID, worldID, roomID string)
- func (cm *CommunicationManager) ValidateMessage(msg *message.Message, senderID string) error
- type PlayerLocation
Constants ¶
const ( MessageTypeSay = message.MessageTypeCustom + 1 MessageTypeShout = message.MessageTypeCustom + 2 MessageTypeEmote = message.MessageTypeCustom + 3 MessageTypeTell = message.MessageTypeCustom + 4 )
Message types for world communication
Variables ¶
This section is empty.
Functions ¶
func CreateEmoteMessage ¶
CreateEmoteMessage creates an emote message
func CreateSayMessage ¶
CreateSayMessage creates a say message
func CreateShoutMessage ¶
CreateShoutMessage creates a shout message
func CreateTellMessage ¶
CreateTellMessage creates a tell message
Types ¶
type Channel ¶
type Channel struct {
ID string
Name string
Type string // "room", "world", "global", "private"
WorldID string // For world-specific channels
RoomID string // For room-specific channels
Members map[string]bool // playerID -> active
CreatedAt time.Time
Properties map[string]interface{}
}
Channel represents a communication channel
type CommunicationBuilder ¶
type CommunicationBuilder struct {
// contains filtered or unexported fields
}
CommunicationBuilder provides a fluent API for building communication messages
func NewCommunicationMessage ¶
func NewCommunicationMessage(messageType int64) *CommunicationBuilder
NewCommunicationMessage creates a new communication message builder
func (*CommunicationBuilder) Build ¶
func (b *CommunicationBuilder) Build() *message.Message
Build returns the constructed message
func (*CommunicationBuilder) FromPlayer ¶
func (b *CommunicationBuilder) FromPlayer(playerID, playerName string) *CommunicationBuilder
FromPlayer sets the sender information
func (*CommunicationBuilder) InRoom ¶
func (b *CommunicationBuilder) InRoom(worldID, roomID string) *CommunicationBuilder
InRoom sets the room context
func (*CommunicationBuilder) RequireAck ¶
func (b *CommunicationBuilder) RequireAck(timeout time.Duration) *CommunicationBuilder
RequireAck enables acknowledgment requirement
func (*CommunicationBuilder) ToPlayer ¶
func (b *CommunicationBuilder) ToPlayer(playerID, playerName string) *CommunicationBuilder
ToPlayer sets the target player for tells
func (*CommunicationBuilder) WithText ¶
func (b *CommunicationBuilder) WithText(text string) *CommunicationBuilder
WithText sets the message text
func (*CommunicationBuilder) WithTimestamp ¶
func (b *CommunicationBuilder) WithTimestamp(timestamp time.Time) *CommunicationBuilder
WithTimestamp sets the timestamp
type CommunicationData ¶
type CommunicationData struct {
Message string `cbor:"message"`
SenderID string `cbor:"sender_id"`
SenderName string `cbor:"sender_name"`
RoomID string `cbor:"room_id,omitempty"`
WorldID string `cbor:"world_id,omitempty"`
TargetID string `cbor:"target_id,omitempty"` // For tells
TargetName string `cbor:"target_name,omitempty"` // For tells
Timestamp int64 `cbor:"timestamp"`
}
CommunicationData represents the data structure for communication messages
func ParseCommunicationMessage ¶
func ParseCommunicationMessage(msg *message.Message) (*CommunicationData, error)
ParseCommunicationMessage parses a communication message
type CommunicationManager ¶
type CommunicationManager struct {
// contains filtered or unexported fields
}
CommunicationManager handles world-aware communication
func NewCommunicationManager ¶
func NewCommunicationManager(storageManager *storage.Manager, eventManager events.EventManager) *CommunicationManager
NewCommunicationManager creates a new communication manager
func (*CommunicationManager) CreateChannel ¶
func (cm *CommunicationManager) CreateChannel(id, name, channelType string) *Channel
CreateChannel creates a new communication channel
func (*CommunicationManager) FilterMessage ¶
func (cm *CommunicationManager) FilterMessage(msg *message.Message, recipientID string) (*message.Message, error)
FilterMessage filters messages based on player permissions or settings
func (*CommunicationManager) GetChannel ¶
func (cm *CommunicationManager) GetChannel(id string) (*Channel, bool)
GetChannel returns a channel by ID
func (*CommunicationManager) GetChannelMembers ¶
func (cm *CommunicationManager) GetChannelMembers(channelID string) []string
GetChannelMembers returns all members of a channel
func (*CommunicationManager) GetMessageHistory ¶
func (cm *CommunicationManager) GetMessageHistory(contextType, contextID string, limit int) ([]*message.Message, error)
GetMessageHistory returns recent messages for a specific context
func (*CommunicationManager) GetPlayerLocation ¶
func (cm *CommunicationManager) GetPlayerLocation(playerID string) (PlayerLocation, bool)
GetPlayerLocation returns a player's current location
func (*CommunicationManager) GetPlayersInRoom ¶
func (cm *CommunicationManager) GetPlayersInRoom(worldID, roomID string) []string
GetPlayersInRoom returns all players in the specified room
func (*CommunicationManager) GetPlayersInWorld ¶
func (cm *CommunicationManager) GetPlayersInWorld(worldID string) []string
GetPlayersInWorld returns all players in the specified world
func (*CommunicationManager) HandleMessage ¶
func (cm *CommunicationManager) HandleMessage(msg *message.Message, senderID string) error
HandleMessage processes a communication message
func (*CommunicationManager) JoinChannel ¶
func (cm *CommunicationManager) JoinChannel(channelID, playerID string) error
JoinChannel adds a player to a channel
func (*CommunicationManager) LeaveChannel ¶
func (cm *CommunicationManager) LeaveChannel(channelID, playerID string) error
LeaveChannel removes a player from a channel
func (*CommunicationManager) RegisterMessageHandler ¶
func (cm *CommunicationManager) RegisterMessageHandler(messageType int64, handler func(*message.Message, string) error)
RegisterMessageHandler registers a custom message handler
func (*CommunicationManager) RemovePlayerLocation ¶
func (cm *CommunicationManager) RemovePlayerLocation(playerID string)
RemovePlayerLocation removes a player's location (when they disconnect)
func (*CommunicationManager) SendToChannel ¶
func (cm *CommunicationManager) SendToChannel(channelID string, msg *message.Message) error
SendToChannel sends a message to all members of a channel
func (*CommunicationManager) SendToPlayer ¶
func (cm *CommunicationManager) SendToPlayer(playerID string, msg *message.Message) error
SendToPlayer sends a message to a specific player
func (*CommunicationManager) SendToRoom ¶
func (cm *CommunicationManager) SendToRoom(worldID, roomID string, msg *message.Message) error
SendToRoom sends a message to all players in a room
func (*CommunicationManager) SendToWorld ¶
func (cm *CommunicationManager) SendToWorld(worldID string, msg *message.Message) error
SendToWorld sends a message to all players in a world
func (*CommunicationManager) UpdatePlayerLocation ¶
func (cm *CommunicationManager) UpdatePlayerLocation(playerID, worldID, roomID string)
UpdatePlayerLocation updates a player's location
func (*CommunicationManager) ValidateMessage ¶
func (cm *CommunicationManager) ValidateMessage(msg *message.Message, senderID string) error
ValidateMessage validates a message before processing