gmcp

package
v0.0.0-...-2f1000c Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializeMessage

func InitializeMessage[T Message, U CreateMessageConstraint[T]](g *GMCP, raw json.RawMessage, message U) error

Types

type Affliction

type Affliction struct {
	Name        string `json:"name"`
	Cure        string `json:"cure"`
	Description string `json:"desc"`
}

type BaseMessage

type BaseMessage struct {
	telopts.BaseTelOptEvent `json:"-"`
	// contains filtered or unexported fields
}

func (*BaseMessage) InitializeAsEvent

func (m *BaseMessage) InitializeAsEvent(g *GMCP, message Message, raw json.RawMessage)

func (BaseMessage) RawMessage

func (m BaseMessage) RawMessage() json.RawMessage

func (BaseMessage) String

func (m BaseMessage) String() string

type CharAfflictionsAddMessage

type CharAfflictionsAddMessage struct {
	BaseMessage

	ValueMessage[[]Affliction]
}

func (CharAfflictionsAddMessage) ID

type CharAfflictionsListMessage

type CharAfflictionsListMessage struct {
	BaseMessage

	ValueMessage[[]Affliction]
}

func (CharAfflictionsListMessage) ID

type CharAfflictionsRemoveMessage

type CharAfflictionsRemoveMessage struct {
	BaseMessage

	ValueMessage[[]string]
}

func (CharAfflictionsRemoveMessage) ID

type CharDefencesAddMessage

type CharDefencesAddMessage struct {
	BaseMessage

	Defence
}

func (CharDefencesAddMessage) ID

type CharDefencesListMessage

type CharDefencesListMessage struct {
	BaseMessage

	ValueMessage[[]Defence]
}

func (CharDefencesListMessage) ID

type CharDefencesRemoveMessage

type CharDefencesRemoveMessage struct {
	BaseMessage

	ValueMessage[[]string]
}

func (CharDefencesRemoveMessage) ID

type CharItemsAddMessage

type CharItemsAddMessage struct {
	BaseMessage

	Location string `json:"location"`
	Item     Item   `json:"item"`
}

func (CharItemsAddMessage) ID

func (m CharItemsAddMessage) ID() string

type CharItemsContentsMessage

type CharItemsContentsMessage struct {
	BaseMessage

	ValueMessage[int]
}

func (CharItemsContentsMessage) ID

type CharItemsInvMessage

type CharItemsInvMessage struct {
	BaseMessage
}

func (CharItemsInvMessage) ID

func (m CharItemsInvMessage) ID() string

type CharItemsListMessage

type CharItemsListMessage struct {
	BaseMessage

	Location string `json:"location"`
	Items    []Item `json:"items"`
}

func (CharItemsListMessage) ID

type CharItemsRemoveMessage

type CharItemsRemoveMessage struct {
	BaseMessage

	Location string `json:"location"`
	Item     Item   `json:"item"`
}

func (CharItemsRemoveMessage) ID

type CharItemsRoomMessage

type CharItemsRoomMessage struct {
	BaseMessage
}

func (CharItemsRoomMessage) ID

type CharItemsUpdateMessage

type CharItemsUpdateMessage struct {
	BaseMessage

	Location string `json:"location"`
	Item     Item   `json:"item"`
}

func (CharItemsUpdateMessage) ID

type CharLoginCredentialsMessage

type CharLoginCredentialsMessage struct {
	BaseMessage

	Account  string `json:"account"`
	Password string `json:"password"`
}

func (CharLoginCredentialsMessage) ID

type CharLoginDefaultMessage

type CharLoginDefaultMessage struct {
	BaseMessage

	Type     []string `json:"type"`
	Location string   `json:"location"`
}

func (CharLoginDefaultMessage) ID

type CharLoginMessage

type CharLoginMessage struct {
	BaseMessage

	Name     string `json:"name"`
	Password string `json:"password"`
}

func (CharLoginMessage) ID

func (m CharLoginMessage) ID() string

type CharLoginResultMessage

type CharLoginResultMessage struct {
	BaseMessage

	Success bool   `json:"success"`
	Message string `json:"message"`
}

func (CharLoginResultMessage) ID

type CharName

type CharName struct {
	Name     string `json:"name"`
	FullName string `json:"fullname"`
}

type CharNameMessage

type CharNameMessage struct {
	BaseMessage

	CharName
}

func (CharNameMessage) ID

func (m CharNameMessage) ID() string

type CharSkillsGetMessage

type CharSkillsGetMessage struct {
	BaseMessage

	Group string `json:"group"`
	Name  string `json:"name"`
}

func (CharSkillsGetMessage) ID

type CharSkillsGroupsMessage

type CharSkillsGroupsMessage struct {
	BaseMessage

	Name string `json:"name"`
	Rank string `json:"rank"`
}

func (CharSkillsGroupsMessage) ID

type CharSkillsInfoMessage

type CharSkillsInfoMessage struct {
	BaseMessage

	Group string `json:"group"`
	Skill string `json:"skill"`
	Info  string `json:"info"`
}

func (CharSkillsInfoMessage) ID

type CharSkillsListMessage

type CharSkillsListMessage struct {
	BaseMessage

	Group       string   `json:"group"`
	Description []string `json:"desc"`
	List        []string `json:"list"`
}

func (CharSkillsListMessage) ID

type CharStatusMessage

type CharStatusMessage struct {
	BaseMessage

	MapMessage
}

func (CharStatusMessage) ID

func (m CharStatusMessage) ID() string

type CharStatusVarsMessage

type CharStatusVarsMessage struct {
	BaseMessage

	MapMessage
}

func (CharStatusVarsMessage) ID

type CharVitalsMessage

type CharVitalsMessage struct {
	BaseMessage

	MapMessage
}

func (CharVitalsMessage) ID

func (m CharVitalsMessage) ID() string

func (*CharVitalsMessage) StringValue

func (m *CharVitalsMessage) StringValue() string

type ClientMapMessage

type ClientMapMessage struct {
	BaseMessage

	URL string `json:"url"`
}

func (ClientMapMessage) ID

func (m ClientMapMessage) ID() string

type ClientMediaDefaultMessage

type ClientMediaDefaultMessage struct {
	BaseMessage

	URL string `json:"url"`
}

func (ClientMediaDefaultMessage) ID

type ClientMediaLoadMessage

type ClientMediaLoadMessage struct {
	BaseMessage

	Name string `json:"name"`
	URL  string `json:"url"`
}

func (ClientMediaLoadMessage) ID

type ClientMediaPlayMessage

type ClientMediaPlayMessage struct {
	BaseMessage

	Name     string `json:"name"`
	URL      string `json:"url"`
	Type     string `json:"type"`
	Tag      string `json:"tag"`
	Volume   int    `json:"volume"`
	FadeIn   int    `json:"fadein"`
	FadeOut  int    `json:"fadeout"`
	Start    int    `json:"start"`
	Finish   int    `json:"finish"`
	Loops    int    `json:"loops"`
	Priority int    `json:"priority"`
	Continue bool   `json:"continue"`
	Key      string `json:"key"`
}

func (ClientMediaPlayMessage) ID

type ClientMediaStopMessage

type ClientMediaStopMessage struct {
	BaseMessage

	Name     string `json:"name"`
	Type     string `json:"type"`
	Tag      string `json:"tag"`
	Priority int    `json:"priority"`
	Key      string `json:"key"`
	FadeAway bool   `json:"fadeaway"`
	FadeOut  int    `json:"fadeout"`
}

func (ClientMediaStopMessage) ID

type CommChannel

type CommChannel struct {
	Name    string `json:"name"`
	Caption string `json:"caption"`
	Command string `json:"command"`
}

type CommChannelEnableMessage

type CommChannelEnableMessage struct {
	BaseMessage

	ValueMessage[string]
}

func (CommChannelEnableMessage) ID

type CommChannelListMessage

type CommChannelListMessage struct {
	BaseMessage

	ValueMessage[[]CommChannel]
}

func (CommChannelListMessage) ID

type CommChannelPlayersClientMessage

type CommChannelPlayersClientMessage struct {
	BaseMessage
}

func (CommChannelPlayersClientMessage) ID

type CommChannelPlayersServerMessage

type CommChannelPlayersServerMessage struct {
	BaseMessage

	ValueMessage[[]CommPlayer]
}

func (CommChannelPlayersServerMessage) ID

type CommChannelTextMessage

type CommChannelTextMessage struct {
	BaseMessage

	Channel string `json:"channel"`
	Talker  string `json:"talker"`
	Text    string `json:"text"`
}

func (CommChannelTextMessage) ID

type CommPlayer

type CommPlayer struct {
	Name     string   `json:"name"`
	Channels []string `json:"channels,omitempty"`
}

type CoreGoodbyeMessage

type CoreGoodbyeMessage struct {
	BaseMessage

	ValueMessage[string]
}

func (CoreGoodbyeMessage) ID

func (m CoreGoodbyeMessage) ID() string

type CoreHelloMessage

type CoreHelloMessage struct {
	BaseMessage

	Client  string `json:"client"`
	Version string `json:"version"`
}

func (CoreHelloMessage) ID

func (m CoreHelloMessage) ID() string

type CoreKeepAliveMessage

type CoreKeepAliveMessage struct {
	BaseMessage
}

func (CoreKeepAliveMessage) ID

type CorePingClientMessage

type CorePingClientMessage struct {
	BaseMessage

	ValueMessage[int]
}

func (CorePingClientMessage) ID

type CorePingServerMessage

type CorePingServerMessage struct {
	BaseMessage
}

func (CorePingServerMessage) ID

type CoreSupportsAddMessage

type CoreSupportsAddMessage struct {
	BaseMessage

	ValueMessage[[]string]
}

func (CoreSupportsAddMessage) ID

type CoreSupportsRemoveMessage

type CoreSupportsRemoveMessage struct {
	BaseMessage

	ValueMessage[[]string]
}

func (CoreSupportsRemoveMessage) ID

type CoreSupportsSetMessage

type CoreSupportsSetMessage struct {
	BaseMessage

	ValueMessage[[]string]
}

func (CoreSupportsSetMessage) ID

type CreateMessageConstraint

type CreateMessageConstraint[T Message] interface {
	*T
	MessageInitialize
}

type Defence

type Defence struct {
	Name        string `json:"name"`
	Description string `json:"desc"`
}

type ExternalDiscordGetMessage

type ExternalDiscordGetMessage struct {
	BaseMessage
}

func (ExternalDiscordGetMessage) ID

type ExternalDiscordHelloMessage

type ExternalDiscordHelloMessage struct {
	BaseMessage

	User    string `json:"user"`
	Private bool   `json:"private"`
}

func (ExternalDiscordHelloMessage) ID

type ExternalDiscordInfoMessage

type ExternalDiscordInfoMessage struct {
	BaseMessage

	InviteURL     string `json:"inviteurl,omitempty"`
	ApplicationID string `json:"applicationid,omitempty"`
}

func (ExternalDiscordInfoMessage) ID

type ExternalDiscordStatusMessage

type ExternalDiscordStatusMessage struct {
	BaseMessage

	SmallImage     []string `json:"smallimage"`
	SmallImageText string   `json:"smallimagetext"`
	Details        string   `json:"details"`
	State          string   `json:"state"`
	PartySize      int      `json:"partysize"`
	PartyMax       int      `json:"partymax"`
	Game           string   `json:"game"`
	StartTime      string   `json:"starttime,omitempty"`
	EndTime        string   `json:"endtime,omitempty"`
}

func (ExternalDiscordStatusMessage) ID

type GMCP

type GMCP struct {
	telopts.BaseTelOpt
	// contains filtered or unexported fields
}

func RegisterGMCP

func RegisterGMCP(usage telnet.TelOptUsage, clientInfo mudopts.ClientInfo, packages ...Package) *GMCP

func (*GMCP) AddPackages

func (g *GMCP) AddPackages(pkgs ...Package) error

func (*GMCP) RemovePackage

func (g *GMCP) RemovePackage(pkgs ...Package) error

func (*GMCP) SendMessage

func (g *GMCP) SendMessage(message Message) error

func (*GMCP) Subnegotiate

func (g *GMCP) Subnegotiate(subnegotiation []byte) error

func (*GMCP) SubnegotiationString

func (g *GMCP) SubnegotiationString(subnegotiation []byte) (string, error)

func (*GMCP) TransitionLocalState

func (g *GMCP) TransitionLocalState(newState telnet.TelOptState) (func() error, error)

func (*GMCP) TransitionRemoteState

func (g *GMCP) TransitionRemoteState(newState telnet.TelOptState) (func() error, error)

type Item

type Item struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	Icon string `json:"icon"`

	Attrib ItemAttributes `json:"attrib"`
}

type ItemAttributes

type ItemAttributes int
const (
	ItemAttWorn ItemAttributes = 1 << iota
	ItemAttWearableNotWorn
	ItemAttWieldedLeft
	ItemAttWieldedRight
	ItemAttGroupable
	ItemAttContainer
	ItemAttRiftable
	ItemAttFluid
	ItemAttEditable
	ItemAttMonster
	ItemAttDeadMonster
	ItemAttTakeable
	ItemAttNoTarget
)

func ParseItemAttributes

func ParseItemAttributes(s string) ItemAttributes

func (*ItemAttributes) MarshalJSON

func (i *ItemAttributes) MarshalJSON() ([]byte, error)

func (ItemAttributes) String

func (a ItemAttributes) String() string

func (*ItemAttributes) UnmarshalJSON

func (i *ItemAttributes) UnmarshalJSON(data []byte) error

type MapMessage

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

func NewMapMessage

func NewMapMessage(ignoreKeys ...string) MapMessage

func (*MapMessage) Keys

func (m *MapMessage) Keys(yield func(string) bool)

func (MapMessage) MarshalJSON

func (m MapMessage) MarshalJSON() ([]byte, error)

func (*MapMessage) SetValue

func (m *MapMessage) SetValue(key string, value any)

func (*MapMessage) UnmarshalJSON

func (m *MapMessage) UnmarshalJSON(data []byte) error

func (*MapMessage) Value

func (m *MapMessage) Value(key string) (any, bool)

type Message

type Message interface {
	ID() string
	RawMessage() json.RawMessage

	telnet.TelOptEvent
}

func CreateMessage

func CreateMessage[T Message, U CreateMessageConstraint[T]](g *GMCP, raw json.RawMessage) (Message, error)

type MessageData

type MessageData struct {
	Sender telnet.TerminalSide
	Create MessageFactory
}

type MessageFactory

type MessageFactory func(g *GMCP, raw json.RawMessage) (Message, error)

type MessageInitialize

type MessageInitialize interface {
	InitializeAsEvent(g *GMCP, message Message, raw json.RawMessage)
}

type Package

type Package struct {
	ID       string
	Version  int
	Messages []MessageData
}

func NewPackageChar

func NewPackageChar() Package

func NewPackageCharAfflictions

func NewPackageCharAfflictions() Package

func NewPackageCharDefences

func NewPackageCharDefences() Package

func NewPackageCharItems

func NewPackageCharItems() Package

func NewPackageCharLogin

func NewPackageCharLogin() Package

func NewPackageCharSkills

func NewPackageCharSkills() Package

func NewPackageClient

func NewPackageClient() Package

func NewPackageClientMedia

func NewPackageClientMedia() Package

func NewPackageCommChannel

func NewPackageCommChannel() Package

func NewPackageCore

func NewPackageCore() Package

func NewPackageExternalDiscord

func NewPackageExternalDiscord() Package

func NewPackageRedirect

func NewPackageRedirect() Package

func NewPackageRoom

func NewPackageRoom() Package

func (Package) AllMessages

func (p Package) AllMessages(yield func(MessageData) bool)

func (Package) Key

func (p Package) Key() string

type RedirectWindowMessage

type RedirectWindowMessage struct {
	BaseMessage

	ValueMessage[string]
}

func (RedirectWindowMessage) ID

type RoomAddPlayerMessage

type RoomAddPlayerMessage struct {
	BaseMessage

	CharName
}

func (RoomAddPlayerMessage) ID

type RoomInfoMessage

type RoomInfoMessage struct {
	BaseMessage

	Number      int            `json:"num"`
	Name        string         `json:"name"`
	Area        string         `json:"area"`
	Environment string         `json:"environment"`
	Coords      string         `json:"coords"`
	Map         string         `json:"map"`
	Details     []string       `json:"details"`
	Exits       map[string]int `json:"exits"`
}

func (RoomInfoMessage) ID

func (m RoomInfoMessage) ID() string

type RoomPlayersMessage

type RoomPlayersMessage struct {
	BaseMessage

	ValueMessage[[]CharName]
}

func (RoomPlayersMessage) ID

func (m RoomPlayersMessage) ID() string

type RoomRemovePlayerMessage

type RoomRemovePlayerMessage struct {
	BaseMessage

	ValueMessage[string]
}

func (RoomRemovePlayerMessage) ID

type RoomWrongDirMessage

type RoomWrongDirMessage struct {
	BaseMessage

	ValueMessage[string]
}

func (RoomWrongDirMessage) ID

func (m RoomWrongDirMessage) ID() string

type UnknownMessage

type UnknownMessage struct {
	telopts.BaseTelOptEvent

	MapMessage
	// contains filtered or unexported fields
}

func (UnknownMessage) ID

func (m UnknownMessage) ID() string

func (UnknownMessage) RawMessage

func (m UnknownMessage) RawMessage() json.RawMessage

func (UnknownMessage) String

func (m UnknownMessage) String() string

type ValueMessage

type ValueMessage[T any] struct {
	Value T
}

func (ValueMessage[T]) MarshalJSON

func (m ValueMessage[T]) MarshalJSON() ([]byte, error)

func (*ValueMessage[T]) UnmarshalJSON

func (m *ValueMessage[T]) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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