Documentation ¶
Index ¶
- Constants
- func EncodeMoneysocketMessage(msg MoneysocketMessage, toEncode map[string]interface{}) error
- type MessageBase
- func (m MessageBase) CryptLevel() string
- func (m MessageBase) IsValid() (bool, error)
- func (m MessageBase) MessageClass() MessageClass
- func (m MessageBase) MustBeClearText() bool
- func (m MessageBase) Protocol() string
- func (m MessageBase) ProtocolVersion() string
- func (m MessageBase) Timestamp() time.Time
- func (m MessageBase) ToJSON() ([]byte, error)
- type MessageClass
- type MessageType
- type MoneysocketMessage
Constants ¶
View Source
const ( ProtocolName = "Moneysocket" Version = "0.0.0" )
View Source
const ( NotificationName = "NOTIFICATION" RequestName = "REQUEST" )
View Source
const ( // requests PingRequest MessageType = 0 ProviderRequest MessageType = iota InvoiceRequest MessageType = iota PayRequest MessageType = iota RendezvousRequest MessageType = iota RequestOpinionSeller MessageType = iota RequestOpinionInvoice MessageType = iota // notifications NotifyRendezvous = iota NotifyRendezvousEndNotification = iota NotifyRendezvousNotReadyNotification = iota NotifyInvoiceNotification = iota NotifyPreimage = iota NotifyProvider = iota NotifyOpinionSeller = iota NotifyOpinionSellerNotReady = iota NotifyProviderNotReady = iota NotifyOpinionInvoice = iota // TODO implement NotifyPing = iota NotifyPong = iota )
View Source
const ( // requests RequestPingName = "REQUEST_PING" RequestProviderName = "REQUEST_PROVIDER" RequestInvoiceName = "REQUEST_INVOICE" RequestPayName = "REQUEST_PAY" RendezvousRequestName = "REQUEST_RENDEZVOUS" RequestOpinionSellerName = "REQUEST_OPINION_SELLER" RequestOpinionInvoiceName = "REQUEST_OPINION_INVOICE" // notifications NotifyNotifyRendezvousEndName = "NOTIFY_RENDEZVOUS_END" NotifyInvoiceName = "NOTIFY_INVOICE" NotifyPreimageName = "NOTIFY_PREIMAGE" NotifyProviderName = "NOTIFY_PROVIDER" NotifyOpinionSellerName = "NOTIFY_OPINION_SELLER" NotifyOpinionSellerNotReadyName = "NOTIFY_OPINION_SELLER_NOT_READY" NotifyOpinionInvoiceName = "NOTIFY_OPINION_INVOICE" NotifyProviderNotReadyName = "NOTIFY_PROVIDER_NOT_READY" NotifyPongName = "NOTIFY_PONG" NotifyRendezvousName = "NOTIFY_RENDEZVOUS" NotifyRendezvousNotReadyName = "NOTIFY_RENDEZVOUS_NOT_READY" )
used for
View Source
const (
MessageClassKey = "message_class"
)
json keys
Variables ¶
This section is empty.
Functions ¶
func EncodeMoneysocketMessage ¶
func EncodeMoneysocketMessage(msg MoneysocketMessage, toEncode map[string]interface{}) error
maps are passed by reference by default https://bit.ly/35KrDps
Types ¶
type MessageBase ¶ added in v0.54.0
type MessageBase struct { // Time is the time Time time.Time // BaseProtocol is the base protocol name BaseProtocol string // BaseProtocolVersion is the protocol version BaseProtocolVersion string // BaseMessageClass is the message class BaseMessageClass MessageClass }
MessageBase is the message
func DecodeBaseBaseMoneysocketMessage ¶ added in v0.54.0
func DecodeBaseBaseMoneysocketMessage(payload []byte) (b MessageBase, err error)
decode a moneysocket message from json
func NewBaseBaseMoneysocketMessage ¶ added in v0.54.0
func NewBaseBaseMoneysocketMessage(messageType MessageClass) MessageBase
func (MessageBase) CryptLevel ¶ added in v0.54.0
func (m MessageBase) CryptLevel() string
func (MessageBase) IsValid ¶ added in v0.54.0
func (m MessageBase) IsValid() (bool, error)
func (MessageBase) MessageClass ¶ added in v0.54.0
func (m MessageBase) MessageClass() MessageClass
func (MessageBase) MustBeClearText ¶ added in v0.54.0
func (m MessageBase) MustBeClearText() bool
func (MessageBase) Protocol ¶ added in v0.54.0
func (m MessageBase) Protocol() string
func (MessageBase) ProtocolVersion ¶ added in v0.54.0
func (m MessageBase) ProtocolVersion() string
func (MessageBase) Timestamp ¶ added in v0.54.0
func (m MessageBase) Timestamp() time.Time
func (MessageBase) ToJSON ¶ added in v0.54.0
func (m MessageBase) ToJSON() ([]byte, error)
type MessageClass ¶
type MessageClass int
const ( Notification MessageClass = 0 Request MessageClass = iota )
func MessageClassFromString ¶
func MessageClassFromString(class string) MessageClass
func (MessageClass) ToString ¶
func (m MessageClass) ToString() string
type MessageType ¶
type MessageType int
TODO: move to map covers both request and notifications
func MessageTypeFromString ¶
func MessageTypeFromString(name string) MessageType
func (MessageType) ToString ¶
func (r MessageType) ToString() string
type MoneysocketMessage ¶
type MoneysocketMessage interface { // get timestamp message was created Timestamp() time.Time // get protocol Protocol() string // get protocol version ProtocolVersion() string // get message class (request or message) MessageClass() MessageClass // convert a message to json ToJSON() ([]byte, error) // wetrher or not the message is valid IsValid() (bool, error) // wether or not a message must be clear text MustBeClearText() bool // encryption level CryptLevel() string }
this is probably one of the worst ways to handle json in go but I wanted to make sure the first vresion was as close to moneysocket as possible architecturally so I could safely refactor with test cases in place
Click to show internal directories.
Click to hide internal directories.