Documentation ¶
Index ¶
- Constants
- func EncodeMoneysocketMessage(msg MoneysocketMessage, toEncode map[string]interface{}) error
- type BaseMoneysocketMessage
- func (m BaseMoneysocketMessage) CryptLevel() string
- func (m BaseMoneysocketMessage) IsValid() (bool, error)
- func (m BaseMoneysocketMessage) MessageClass() MessageClass
- func (m BaseMoneysocketMessage) MustBeClearText() bool
- func (m BaseMoneysocketMessage) Protocol() string
- func (m BaseMoneysocketMessage) ProtocolVersion() string
- func (m BaseMoneysocketMessage) Timestamp() time.Time
- func (m BaseMoneysocketMessage) ToJson() ([]byte, error)
- type MessageClass
- type MessageType
- type MoneysocketMessage
Constants ¶
View Source
const ( PROTOCOL_NAME = "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 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 BaseMoneysocketMessage ¶
type BaseMoneysocketMessage struct { Time time.Time BaseProtocol string BaseProtocolVersion string BaseMessageClass MessageClass }
func DecodeBaseMoneysocketMessage ¶
func DecodeBaseMoneysocketMessage(payload []byte) (b BaseMoneysocketMessage, err error)
decode a moneysocket message from json
func NewBaseMoneysocketMessage ¶
func NewBaseMoneysocketMessage(messageType MessageClass) BaseMoneysocketMessage
func (BaseMoneysocketMessage) CryptLevel ¶
func (m BaseMoneysocketMessage) CryptLevel() string
func (BaseMoneysocketMessage) IsValid ¶
func (m BaseMoneysocketMessage) IsValid() (bool, error)
func (BaseMoneysocketMessage) MessageClass ¶
func (m BaseMoneysocketMessage) MessageClass() MessageClass
func (BaseMoneysocketMessage) MustBeClearText ¶
func (m BaseMoneysocketMessage) MustBeClearText() bool
func (BaseMoneysocketMessage) Protocol ¶
func (m BaseMoneysocketMessage) Protocol() string
func (BaseMoneysocketMessage) ProtocolVersion ¶
func (m BaseMoneysocketMessage) ProtocolVersion() string
func (BaseMoneysocketMessage) Timestamp ¶
func (m BaseMoneysocketMessage) Timestamp() time.Time
func (BaseMoneysocketMessage) ToJson ¶
func (m BaseMoneysocketMessage) 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
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.