Documentation
¶
Index ¶
- func ClientMessageTypeNames() []string
- func NewPairMessage(id string) *pairMessage
- func NewStateUpdateMessage(id string, value string) *stateUpdateMessage
- type ActionMessage
- type Client
- func (c *Client) AddMessageHandler(msgType ClientMessageType, handler func(e interface{}))
- func (c *Client) Close()
- func (c *Client) Dispatch(mType ClientMessageType, event interface{})
- func (c *Client) Ready() <-chan bool
- func (c *Client) Run(ctx context.Context)
- func (c *Client) SendMessage(m interface{}) error
- func (c *Client) SetMessageProcessor(msgType ClientMessageType, ...)
- type ClientMessageType
- func (i ClientMessageType) IsAClientMessageType() bool
- func (i ClientMessageType) MarshalJSON() ([]byte, error)
- func (i ClientMessageType) MarshalText() ([]byte, error)
- func (i ClientMessageType) MarshalYAML() (interface{}, error)
- func (i *ClientMessageType) Scan(value interface{}) error
- func (i ClientMessageType) String() string
- func (i *ClientMessageType) UnmarshalJSON(data []byte) error
- func (i *ClientMessageType) UnmarshalText(text []byte) error
- func (i *ClientMessageType) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (i ClientMessageType) Value() (driver.Value, error)
- type ClosePluginMessage
- type InfoMessage
- type Message
- type SettingsMessage
- type Socket
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientMessageTypeNames ¶
func ClientMessageTypeNames() []string
func NewPairMessage ¶
func NewPairMessage(id string) *pairMessage
NewPairMessage provides a ready to go client.pairMessage that can be sent to TouchPortal as a part of the plugin registration flow.
func NewStateUpdateMessage ¶
NewStateUpdateMessage provides a ready to go client.stateUpdateMessage that can be sent to TouchPortal.
Types ¶
type ActionMessage ¶
type ActionMessage struct { Message PluginID string `json:"pluginId"` ActionID string `json:"actionId"` Data json.RawMessage `json:"data"` }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AddMessageHandler ¶
func (c *Client) AddMessageHandler(msgType ClientMessageType, handler func(e interface{}))
func (*Client) Dispatch ¶
func (c *Client) Dispatch(mType ClientMessageType, event interface{})
func (*Client) SendMessage ¶
SendMessage will send a JSON serialised version of the passed interface{} to TouchPortal, returning an error if it was unable to complete the task
func (*Client) SetMessageProcessor ¶
func (c *Client) SetMessageProcessor(msgType ClientMessageType, processor func(msg json.RawMessage) (interface{}, error))
SetMessageProcessor lets you use your own handling of incoming message types. Your provided processor function should turn the provided raw JSON into the interface you're expecting - probably a struct of some sort.
type ClientMessageType ¶
type ClientMessageType int
const ( MessageTypeAction ClientMessageType = iota MessageTypeClosePlugin MessageTypeInfo MessageTypePair MessageTypeSettings MessageTypeStateUpdate )
func ClientMessageTypeString ¶
func ClientMessageTypeString(s string) (ClientMessageType, error)
ClientMessageTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func ClientMessageTypeValues ¶
func ClientMessageTypeValues() []ClientMessageType
ClientMessageTypeValues returns all values of the enum
func ParseClientMessageType ¶
func ParseClientMessageType(s string) (ClientMessageType, error)
func (ClientMessageType) IsAClientMessageType ¶
func (i ClientMessageType) IsAClientMessageType() bool
IsAClientMessageType returns "true" if the value is listed in the enum definition. "false" otherwise
func (ClientMessageType) MarshalJSON ¶
func (i ClientMessageType) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for ClientMessageType
func (ClientMessageType) MarshalText ¶
func (i ClientMessageType) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for ClientMessageType
func (ClientMessageType) MarshalYAML ¶
func (i ClientMessageType) MarshalYAML() (interface{}, error)
MarshalYAML implements a YAML Marshaler for ClientMessageType
func (*ClientMessageType) Scan ¶
func (i *ClientMessageType) Scan(value interface{}) error
func (ClientMessageType) String ¶
func (i ClientMessageType) String() string
func (*ClientMessageType) UnmarshalJSON ¶
func (i *ClientMessageType) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for ClientMessageType
func (*ClientMessageType) UnmarshalText ¶
func (i *ClientMessageType) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for ClientMessageType
func (*ClientMessageType) UnmarshalYAML ¶
func (i *ClientMessageType) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements a YAML Unmarshaler for ClientMessageType
type ClosePluginMessage ¶
type InfoMessage ¶
type Message ¶
type Message struct {
Type ClientMessageType `json:"type"`
}
type SettingsMessage ¶
type SettingsMessage struct { Message RawValues json.RawMessage `json:"values"` Values map[string]interface{} }
type Socket ¶
type Socket struct {
// contains filtered or unexported fields
}
func (*Socket) Close ¶
func (s *Socket) Close()
Close will close the underlying communication socket
func (*Socket) GetMessage ¶
GetMessage reads a single line from the connection. It blocks for a duration but plays nice and returns after the a 300ms deadline so you can handle graceful shutdowns.
func (*Socket) SendMessage ¶
SendMessage is a blocking call to send a message out via the socket