message

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeAuth added in v0.0.5

func MakeAuth(challenge string) []byte

MakeAuth constructs a NIP-01 OK message to be sent to the client.

func MakeClosed

func MakeClosed(id, reason string) []byte

MakeClosed constructs a CLOSED message to be sent to client.

func MakeEOSE

func MakeEOSE(sID string) []byte

func MakeEvent

func MakeEvent(id string, e *event.Event) []byte

MakeEvent constructs an EVENT message to be sent to client.

func MakeNotice

func MakeNotice(msg string) []byte

func MakeOK

func MakeOK(ok bool, eid, reason string) []byte

MakeOK constructs a NIP-01 OK message to be sent to the client.

Types

type Auth

type Auth struct {
	Challenge string
	Event     event.Event
}

Auth reperesents a NIP-01 AUTH message.

func (*Auth) DecodeFromJSON

func (am *Auth) DecodeFromJSON(data []byte) error

func (*Auth) EncodeToJSON

func (am *Auth) EncodeToJSON() ([]byte, error)

func (Auth) String

func (am Auth) String() string

func (Auth) Type

func (Auth) Type() string

type Close

type Close string

Close reperesents a NIP-01 CLOSE message.

func (*Close) DecodeFromJSON

func (cm *Close) DecodeFromJSON(data []byte) error

func (Close) EncodeToJSON

func (cm Close) EncodeToJSON() ([]byte, error)

func (Close) String

func (cm Close) String() string

func (Close) Type

func (Close) Type() string

type Closed

type Closed struct {
	SubscriptionID string
	Reason         string
}

Closed reperesents a NIP-01 CLOSED message.

func (*Closed) DecodeFromJSON

func (cm *Closed) DecodeFromJSON(_ []byte) error

func (Closed) EncodeToJSON

func (cm Closed) EncodeToJSON() ([]byte, error)

func (Closed) Label

func (Closed) Label() string

func (Closed) String

func (cm Closed) String() string

type EOSE

type EOSE string

EOSE reperesents a NIP-01 EOSE message.

func (*EOSE) DecodeFromJSON

func (em *EOSE) DecodeFromJSON(_ []byte) error

func (EOSE) EncodeToJSON

func (em EOSE) EncodeToJSON() ([]byte, error)

func (EOSE) String

func (em EOSE) String() string

func (EOSE) Type

func (EOSE) Type() string

type Event

type Event struct {
	SubscriptionID string
	Event          *event.Event
}

Event represents a NIP-01 EVENT message.

func (*Event) DecodeFromJSON

func (em *Event) DecodeFromJSON(data []byte) error

func (Event) EncodeToJSON

func (em Event) EncodeToJSON() ([]byte, error)

func (Event) String

func (em Event) String() string

func (Event) Type

func (Event) Type() string

type Message

type Message interface {
	Type() string
	DecodeFromJSON([]byte) error
	EncodeToJSON() ([]byte, error)
	String() string
}

Message reperesents an NIP-01 message which can be sent to or received by client.

func ParseMessage

func ParseMessage(message []byte) (Message, error)

ParseMessage parses the given message from client to a message interface.

type Notice

type Notice string

Notice reperesents a NIP-01 NOTICE message.

func (*Notice) DecodeFromJSON

func (nm *Notice) DecodeFromJSON(_ []byte) error

func (Notice) EncodeToJSON

func (nm Notice) EncodeToJSON() ([]byte, error)

func (Notice) String

func (nm Notice) String() string

func (Notice) Type

func (Notice) Type() string

type OK

type OK struct {
	OK      bool
	EventID string
	Reason  string
}

OK reperesents a NIP-01 OK message.

func (*OK) DecodeFromJSON

func (om *OK) DecodeFromJSON(_ []byte) error

func (OK) EncodeToJSON

func (om OK) EncodeToJSON() ([]byte, error)

func (OK) String

func (om OK) String() string

func (OK) Type

func (OK) Type() string

type Req

type Req struct {
	SubscriptionID string
	filter.Filters
}

Req reperesents a NIP-01 REQ message.

func (*Req) DecodeFromJSON

func (rm *Req) DecodeFromJSON(data []byte) error

func (Req) EncodeToJSON

func (rm Req) EncodeToJSON() ([]byte, error)

func (Req) Type

func (Req) Type() string

Jump to

Keyboard shortcuts

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