canopus: github.com/zubairhamed/canopus Index | Files

package canopus

import "github.com/zubairhamed/canopus"

Index

Package Files

bytecontent.go canopus.go client.go conn.go corelink.go coreresource.go dtls.go empty.go event.go init.go json.go message.go options.go plaintext.go proxy.go request.go response.go routes.go server.go serverconn.go session.go types.go utildebug.go utils.go xml.go

Constants

const (
    MessageConfirmable    = 0
    MessageNonConfirmable = 1
    MessageAcknowledgment = 2
    MessageReset          = 3
)

Types of Messages

const (
    DataHeader     = 0
    DataCode       = 1
    DataMsgIDStart = 2
    DataMsgIDEnd   = 4
    DataTokenStart = 4
)

Fragments/parts of a CoAP Message packet

const (
    MethodGet     = "GET"
    MethodPut     = "PUT"
    MethodPost    = "POST"
    MethodDelete  = "DELETE"
    MethodOptions = "OPTIONS"
    MethodPatch   = "PATCH"
)
const (
    SecNoSec        = "NoSec"
    SecPreSharedKey = "PreSharedKey"
    SecRawPublicKey = "RawPublicKey"
    SecCertificate  = "Certificate"
)

Security Options

const CoapDefaultHost = ""
const CoapDefaultPort = 5683
const CoapsDefaultPort = 5684
const DefaultAckRandomFactor = 1.5
const DefaultAckTimeout = 2
const DefaultLeisure = 5
const DefaultMaxRetransmit = 4
const DefaultNStart = 1
const DefaultProbingRate = 1
const MaxPacketSize = 1500
const MessageIDPurgeDuration = 60

MessageIDPurgeDuration defines the number of seconds before a MessageID Purge is initiated

const PayloadMarker = 0xff
const UDP = "udp"

Variables

var CurrentMessageID = 0

CurrentMessageID stores the current message id used/generated for messages

var DTLS_CLIENT_CONNECTIONS = make(map[int32]*DTLSConnection)
var DTLS_SERVER_SESSIONS = make(map[int32]*DTLSServerSession)
var ErrInvalidCoapVersion = errors.New("Invalid CoAP version. Should be 1.")
var ErrInvalidTokenLength = errors.New("Invalid Token Length ( > 8)")
var ErrMessageSizeTooLongBlockOptionValNotSet = errors.New("Message is too long, block option or value not set")
var ErrNilAddr = errors.New("Address cannot be nil")
var ErrNilConn = errors.New("Connection object is nil")
var ErrNilMessage = errors.New("Message is nil")
var ErrNoMatchingMethod = errors.New("No matching method")
var ErrNoMatchingRoute = errors.New("No matching route found")
var ErrOptionDeltaUsesValue15 = errors.New(("Message format error. Option delta has reserved value of 15"))
var ErrOptionLengthUsesValue15 = errors.New(("Message format error. Option length has reserved value of 15"))
var ErrPacketLengthLessThan4 = errors.New("Packet length less than 4 bytes")

Errors

var ErrUnknownCriticalOption = errors.New("Unknown critical option encountered")
var ErrUnknownMessageType = errors.New("Unknown message type")
var ErrUnsupportedContentFormat = errors.New("Unsupported Content-Format")
var ErrUnsupportedMethod = errors.New("Unsupported Method")
var GENERATE_ID uint16 = 0
var MESSAGEID_MUTEX *sync.Mutex
var NEXT_SESSION_ID int32 = 0

func AddResponseChannel Uses

func AddResponseChannel(c CoapServer, msgId uint16, ch chan *CoapResponseChannel)

func COAPProxyHandler Uses

func COAPProxyHandler(c CoapServer, msg Message, session Session)

func CoapCodeToString Uses

func CoapCodeToString(code CoapCode) string

CoapCodeToString returns the string representation of a CoapCode

func DeleteResponseChannel Uses

func DeleteResponseChannel(c CoapServer, msgId uint16)

func GenerateMessageID Uses

func GenerateMessageID() uint16

GenerateMessageId generate a uint16 Message ID

func GenerateToken Uses

func GenerateToken(l int) string

GenerateToken generates a random token by a given length

func GetResponseChannel Uses

func GetResponseChannel(c CoapServer, msgId uint16) (ch chan *CoapResponseChannel)

func HTTPCOAPProxyHandler Uses

func HTTPCOAPProxyHandler(msg *Message, conn *net.UDPConn, addr net.Addr)

Handles requests for proxying from HTTP to CoAP

func HTTPProxyHandler Uses

func HTTPProxyHandler(c CoapServer, msg Message, session Session)

Handles requests for proxying from CoAP to HTTP

func IsCoapURI Uses

func IsCoapURI(uri string) bool

Determines if a message contains URI targeting a CoAP resource

func IsCriticalOption Uses

func IsCriticalOption(opt Option) bool

Determines if an option is critical

func IsElectiveOption Uses

func IsElectiveOption(opt Option) bool

Determines if an option is elective

func IsHTTPURI Uses

func IsHTTPURI(uri string) bool

Determines if a message contains URI targeting an HTTP resource

func IsProxyRequest Uses

func IsProxyRequest(msg Message) bool

Determines if a message contains options for proxying (i.e. Proxy-Scheme or Proxy-Uri)

func IsRepeatableOption Uses

func IsRepeatableOption(opt Option) bool

Checks if an option is repeatable

func IsValidOption Uses

func IsValidOption(opt Option) bool

Checks if an option/option code is recognizable/valid

func MessageSizeAllowed Uses

func MessageSizeAllowed(req Request) bool

func MessageToBytes Uses

func MessageToBytes(msg Message) ([]byte, error)

Converts a message object to a byte array. Typically done prior to transmission

func MethodString Uses

func MethodString(c CoapCode) string

Gets the string representation of a CoAP Method code (e.g. GET, PUT, DELETE etc)

func NewResponseChannel Uses

func NewResponseChannel() (ch chan *CoapResponseChannel)

func NullProxyFilter Uses

func NullProxyFilter(Message, net.Addr) bool

func NullProxyHandler Uses

func NullProxyHandler(c CoapServer, msg Message, session Session)

The default handler when proxying is disabled

func OptionNumberToString Uses

func OptionNumberToString(o OptionCode) string

OptionNumberToString returns the string representation of a given Option Code

func PayloadAsString Uses

func PayloadAsString(p MessagePayload) string

Returns the string value for a Message Payload

func PrintMessage Uses

func PrintMessage(msg Message)

PrintMessage pretty prints out a given Message

func PrintOptions Uses

func PrintOptions(msg Message)

PrintOptions pretty prints out a given Message's options

func ValidCoapMediaTypeCode Uses

func ValidCoapMediaTypeCode(mt MediaType) bool

ValidCoapMediaTypeCode Checks if a MediaType is of a valid code

func ValidateMessage Uses

func ValidateMessage(msg Message) error

Validates a message object and returns any error upon validation failure

type Block1Option Uses

type Block1Option struct {
    CoapOption
}

func Block1OptionFromOption Uses

func Block1OptionFromOption(opt Option) *Block1Option

func NewBlock1Option Uses

func NewBlock1Option(bs BlockSizeType, more bool, seq uint32) *Block1Option

func (*Block1Option) BlockSizeLength Uses

func (o *Block1Option) BlockSizeLength() uint32

func (*Block1Option) Exponent Uses

func (o *Block1Option) Exponent() uint32

func (*Block1Option) HasMore Uses

func (o *Block1Option) HasMore() bool

func (*Block1Option) Sequence Uses

func (o *Block1Option) Sequence() uint32

func (*Block1Option) Size Uses

func (o *Block1Option) Size() BlockSizeType

type BlockMessage Uses

type BlockMessage interface {
}

func NewBlockMessage Uses

func NewBlockMessage() BlockMessage

type BlockSizeType Uses

type BlockSizeType byte
const (
    BlockSize16   BlockSizeType = 0
    BlockSize32   BlockSizeType = 1
    BlockSize64   BlockSizeType = 2
    BlockSize128  BlockSizeType = 3
    BlockSize256  BlockSizeType = 4
    BlockSize512  BlockSizeType = 5
    BlockSize1024 BlockSizeType = 6
)

type BySequence Uses

type BySequence []*CoapBlockMessage

func (BySequence) Len Uses

func (o BySequence) Len() int

func (BySequence) Less Uses

func (o BySequence) Less(i, j int) bool

func (BySequence) Swap Uses

func (o BySequence) Swap(i, j int)

type BytesPayload Uses

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

func (*BytesPayload) GetBytes Uses

func (p *BytesPayload) GetBytes() []byte

func (*BytesPayload) Length Uses

func (p *BytesPayload) Length() int

func (*BytesPayload) String Uses

func (p *BytesPayload) String() string

type CoapBlockMessage Uses

type CoapBlockMessage struct {
    CoapMessage
    MessageBuf []byte
    Sequence   uint32
}

type CoapCode Uses

type CoapCode uint8

CoapCode defines a valid CoAP Code Type

const (
    Get    CoapCode = 1
    Post   CoapCode = 2
    Put    CoapCode = 3
    Delete CoapCode = 4

    // 2.x
    CoapCodeEmpty    CoapCode = 0
    CoapCodeCreated  CoapCode = 65 // 2.01
    CoapCodeDeleted  CoapCode = 66 // 2.02
    CoapCodeValid    CoapCode = 67 // 2.03
    CoapCodeChanged  CoapCode = 68 // 2.04
    CoapCodeContent  CoapCode = 69 // 2.05
    CoapCodeContinue CoapCode = 95 // 2.31

    // 4.x
    CoapCodeBadRequest               CoapCode = 128 // 4.00
    CoapCodeUnauthorized             CoapCode = 129 // 4.01
    CoapCodeBadOption                CoapCode = 130 // 4.02
    CoapCodeForbidden                CoapCode = 131 // 4.03
    CoapCodeNotFound                 CoapCode = 132 // 4.04
    CoapCodeMethodNotAllowed         CoapCode = 133 // 4.05
    CoapCodeNotAcceptable            CoapCode = 134 // 4.06
    CoapCodeRequestEntityIncomplete  CoapCode = 136 // 4.08
    CoapCodeConflict                 CoapCode = 137 // 4.09
    CoapCodePreconditionFailed       CoapCode = 140 // 4.12
    CoapCodeRequestEntityTooLarge    CoapCode = 141 // 4.13
    CoapCodeUnsupportedContentFormat CoapCode = 143 // 4.15

    // 5.x
    CoapCodeInternalServerError  CoapCode = 160 // 5.00
    CoapCodeNotImplemented       CoapCode = 161 // 5.01
    CoapCodeBadGateway           CoapCode = 162 // 5.02
    CoapCodeServiceUnavailable   CoapCode = 163 // 5.03
    CoapCodeGatewayTimeout       CoapCode = 164 // 5.04
    CoapCodeProxyingNotSupported CoapCode = 165 // 5.05
)

type CoapMessage Uses

type CoapMessage struct {
    MessageType uint8
    Code        CoapCode
    MessageID   uint16
    Payload     MessagePayload
    Token       []byte
    Options     []Option
}

A Message object represents a CoAP payload

func (*CoapMessage) AddOption Uses

func (m *CoapMessage) AddOption(code OptionCode, value interface{})

Add an Option to the message. If an option is not repeatable, it will replace any existing defined Option of the same type

func (*CoapMessage) AddOptions Uses

func (m *CoapMessage) AddOptions(opts []Option)

Add an array of Options to the message. If an option is not repeatable, it will replace any existing defined Option of the same type

func (*CoapMessage) CloneOptions Uses

func (m *CoapMessage) CloneOptions(cm Message, opts ...OptionCode)

Copies the given list of options from another message to this one

func (*CoapMessage) GetAcceptedContent Uses

func (m *CoapMessage) GetAcceptedContent() MediaType

func (*CoapMessage) GetAllOptions Uses

func (m *CoapMessage) GetAllOptions() []Option

func (*CoapMessage) GetCode Uses

func (m *CoapMessage) GetCode() CoapCode

func (*CoapMessage) GetCodeString Uses

func (m *CoapMessage) GetCodeString() string

func (*CoapMessage) GetLocationPath Uses

func (m *CoapMessage) GetLocationPath() string

Returns the string value of the Location Path Options by joining and defining a / separator

func (*CoapMessage) GetMessageId Uses

func (m *CoapMessage) GetMessageId() uint16

func (*CoapMessage) GetMessageType Uses

func (m *CoapMessage) GetMessageType() uint8

func (*CoapMessage) GetMethod Uses

func (m *CoapMessage) GetMethod() uint8

func (CoapMessage) GetOption Uses

func (m CoapMessage) GetOption(id OptionCode) Option

Returns the first option found for a given option code

func (CoapMessage) GetOptions Uses

func (m CoapMessage) GetOptions(id OptionCode) []Option

Returns an array of options given an option code

func (CoapMessage) GetOptionsAsString Uses

func (m CoapMessage) GetOptionsAsString(id OptionCode) []string

Attempts to return the string value of an Option

func (*CoapMessage) GetPayload Uses

func (m *CoapMessage) GetPayload() MessagePayload

func (*CoapMessage) GetToken Uses

func (m *CoapMessage) GetToken() []byte

func (*CoapMessage) GetTokenLength Uses

func (m *CoapMessage) GetTokenLength() uint8

func (*CoapMessage) GetTokenString Uses

func (m *CoapMessage) GetTokenString() string

func (CoapMessage) GetURIPath Uses

func (m CoapMessage) GetURIPath() string

Returns the string value of the Uri Path Options by joining and defining a / separator

func (*CoapMessage) RemoveOptions Uses

func (m *CoapMessage) RemoveOptions(id OptionCode)

Removes an Option

func (*CoapMessage) ReplaceOptions Uses

func (m *CoapMessage) ReplaceOptions(code OptionCode, opts []Option)

Replace an Option

func (*CoapMessage) SetBlock1Option Uses

func (c *CoapMessage) SetBlock1Option(opt Option)

func (*CoapMessage) SetMessageId Uses

func (m *CoapMessage) SetMessageId(id uint16)

func (*CoapMessage) SetMessageType Uses

func (m *CoapMessage) SetMessageType(t uint8)

func (*CoapMessage) SetPayload Uses

func (m *CoapMessage) SetPayload(p MessagePayload)

func (*CoapMessage) SetStringPayload Uses

func (m *CoapMessage) SetStringPayload(s string)

Adds a string payload

func (*CoapMessage) SetToken Uses

func (m *CoapMessage) SetToken(t []byte)

type CoapObserveMessage Uses

type CoapObserveMessage struct {
    CoapMessage
    Resource string
    Value    interface{}
    Msg      Message
}

func (*CoapObserveMessage) GetMessage Uses

func (m *CoapObserveMessage) GetMessage() Message

func (*CoapObserveMessage) GetResource Uses

func (m *CoapObserveMessage) GetResource() string

func (*CoapObserveMessage) GetValue Uses

func (m *CoapObserveMessage) GetValue() interface{}

type CoapOption Uses

type CoapOption struct {
    Code  OptionCode
    Value interface{}
}

Represents an Option for a CoAP Message

func NewOption Uses

func NewOption(optionNumber OptionCode, optionValue interface{}) *CoapOption

Instantiates a New Option

func (*CoapOption) GetCode Uses

func (o *CoapOption) GetCode() OptionCode

func (*CoapOption) GetValue Uses

func (o *CoapOption) GetValue() interface{}

func (*CoapOption) IntValue Uses

func (o *CoapOption) IntValue() int

func (*CoapOption) IsCritical Uses

func (o *CoapOption) IsCritical() bool

Determines if an option is critical

func (*CoapOption) IsElective Uses

func (o *CoapOption) IsElective() bool

Determines if an option is elective

func (*CoapOption) Name Uses

func (o *CoapOption) Name() string

func (*CoapOption) StringValue Uses

func (o *CoapOption) StringValue() string

Returns the string value of an option

type CoapRequest Uses

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

Wraps a CoAP Message as a Request Provides various methods which proxies the Message object methods

func (*CoapRequest) GetAttribute Uses

func (c *CoapRequest) GetAttribute(o string) string

func (*CoapRequest) GetAttributeAsInt Uses

func (c *CoapRequest) GetAttributeAsInt(o string) int

func (*CoapRequest) GetAttributes Uses

func (c *CoapRequest) GetAttributes() map[string]string

func (*CoapRequest) GetMessage Uses

func (c *CoapRequest) GetMessage() Message

func (*CoapRequest) GetSession Uses

func (c *CoapRequest) GetSession() Session

func (*CoapRequest) GetURIQuery Uses

func (c *CoapRequest) GetURIQuery(q string) string

func (*CoapRequest) SetConfirmable Uses

func (c *CoapRequest) SetConfirmable(con bool)

func (*CoapRequest) SetMediaType Uses

func (c *CoapRequest) SetMediaType(mt MediaType)

func (*CoapRequest) SetPayload Uses

func (c *CoapRequest) SetPayload(b []byte)

func (*CoapRequest) SetProxyURI Uses

func (c *CoapRequest) SetProxyURI(uri string)

func (*CoapRequest) SetRequestURI Uses

func (c *CoapRequest) SetRequestURI(uri string)

func (*CoapRequest) SetStringPayload Uses

func (c *CoapRequest) SetStringPayload(s string)

func (*CoapRequest) SetToken Uses

func (c *CoapRequest) SetToken(t string)

func (*CoapRequest) SetURIQuery Uses

func (c *CoapRequest) SetURIQuery(k string, v string)

type CoapResponseChannel Uses

type CoapResponseChannel struct {
    Response Response
    Error    error
}

type CoapServer Uses

type CoapServer interface {
    ListenAndServe(addr string)
    ListenAndServeDTLS(addr string)
    Stop()

    Get(path string, fn RouteHandler) Route
    Delete(path string, fn RouteHandler) Route
    Put(path string, fn RouteHandler) Route
    Post(path string, fn RouteHandler) Route
    Options(path string, fn RouteHandler) Route
    Patch(path string, fn RouteHandler) Route

    NewRoute(path string, method CoapCode, fn RouteHandler) Route
    NotifyChange(resource, value string, confirm bool)

    OnNotify(fn FnEventNotify)
    OnStart(fn FnEventStart)
    OnClose(fn FnEventClose)
    OnDiscover(fn FnEventDiscover)
    OnError(fn FnEventError)
    OnObserve(fn FnEventObserve)
    OnObserveCancel(fn FnEventObserveCancel)
    OnMessage(fn FnEventMessage)
    OnBlockMessage(fn FnEventBlockMessage)

    ProxyOverHttp(enabled bool)
    ProxyOverCoap(enabled bool)

    GetEvents() Events

    AllowProxyForwarding(Message, net.Addr) bool
    GetRoutes() []Route
    ForwardCoap(msg Message, session Session)
    ForwardHTTP(msg Message, session Session)

    AddObservation(resource, token string, session Session)
    HasObservation(resource string, addr net.Addr) bool
    RemoveObservation(resource string, addr net.Addr)

    HandlePSK(func(id string) []byte)

    GetSession(addr string) Session
    DeleteSession(ssn Session)

    GetCookieSecret() []byte
}

Interfaces

func NewServer Uses

func NewServer() CoapServer

type Connection Uses

type Connection interface {
    ObserveResource(resource string) (tok string, err error)
    CancelObserveResource(resource string, token string) (err error)
    StopObserve(ch chan ObserveMessage)
    Observe(ch chan ObserveMessage)
    Send(req Request) (resp Response, err error)

    Write(b []byte) (n int, err error)
    Read(b []byte) (n int, err error)
    Close() error
}

func Dial Uses

func Dial(address string) (conn Connection, err error)

func DialDTLS Uses

func DialDTLS(address, identity, psk string) (conn Connection, err error)

func NewDTLSConnection Uses

func NewDTLSConnection(c net.Conn, identity, psk string) (conn Connection, err error)

Client DTLS

type CoreAttribute Uses

type CoreAttribute struct {
    Key   string
    Value interface{}
}

func NewCoreAttribute Uses

func NewCoreAttribute(key string, value interface{}) *CoreAttribute

Instantiates a new core-attribute with a given key/value

type CoreAttributes Uses

type CoreAttributes []*CoreAttribute

type CoreLinkFormatPayload Uses

type CoreLinkFormatPayload struct {
}

Represents a message payload containing core-link format values

func (*CoreLinkFormatPayload) GetBytes Uses

func (p *CoreLinkFormatPayload) GetBytes() []byte

func (*CoreLinkFormatPayload) Length Uses

func (p *CoreLinkFormatPayload) Length() int

func (*CoreLinkFormatPayload) String Uses

func (p *CoreLinkFormatPayload) String() string

type CoreResource Uses

type CoreResource struct {
    Target     string
    Attributes CoreAttributes
}

func CoreResourcesFromString Uses

func CoreResourcesFromString(str string) []*CoreResource

CoreResourcesFromString Converts to CoRE Resources Object from a CoRE String

func NewCoreResource Uses

func NewCoreResource() *CoreResource

Instantiates a new Core Resource Object

func (*CoreResource) AddAttribute Uses

func (c *CoreResource) AddAttribute(key string, value interface{})

Adds an attribute (key/value) for a given core resource

func (*CoreResource) GetAttribute Uses

func (c *CoreResource) GetAttribute(key string) *CoreAttribute

Gets an attribute for a core resource

type DTLSConnection Uses

type DTLSConnection struct {
    UDPConnection
    // contains filtered or unexported fields
}

func (*DTLSConnection) CancelObserveResource Uses

func (c *DTLSConnection) CancelObserveResource(resource string, token string) (err error)

func (*DTLSConnection) Close Uses

func (c *DTLSConnection) Close() error

func (*DTLSConnection) Observe Uses

func (c *DTLSConnection) Observe(ch chan ObserveMessage)

func (*DTLSConnection) ObserveResource Uses

func (c *DTLSConnection) ObserveResource(resource string) (tok string, err error)

func (*DTLSConnection) Read Uses

func (c *DTLSConnection) Read(b []byte) (int, error)

func (*DTLSConnection) Send Uses

func (c *DTLSConnection) Send(req Request) (resp Response, err error)

func (*DTLSConnection) StopObserve Uses

func (c *DTLSConnection) StopObserve(ch chan ObserveMessage)

func (*DTLSConnection) Write Uses

func (c *DTLSConnection) Write(b []byte) (int, error)

type DTLSServerSession Uses

type DTLSServerSession struct {
    UDPServerSession
    // contains filtered or unexported fields
}

func (*DTLSServerSession) GetConnection Uses

func (s *DTLSServerSession) GetConnection() ServerConnection

func (*DTLSServerSession) Read Uses

func (s *DTLSServerSession) Read(b []byte) (n int, err error)

func (*DTLSServerSession) Write Uses

func (s *DTLSServerSession) Write(b []byte) (int, error)

type DefaultCoapServer Uses

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

func (*DefaultCoapServer) AddObservation Uses

func (s *DefaultCoapServer) AddObservation(resource, token string, session Session)

func (*DefaultCoapServer) AllowProxyForwarding Uses

func (s *DefaultCoapServer) AllowProxyForwarding(msg Message, addr net.Addr) bool

func (*DefaultCoapServer) Delete Uses

func (s *DefaultCoapServer) Delete(path string, fn RouteHandler) Route

func (*DefaultCoapServer) DeleteSession Uses

func (s *DefaultCoapServer) DeleteSession(ssn Session)

func (*DefaultCoapServer) ForwardCoap Uses

func (s *DefaultCoapServer) ForwardCoap(msg Message, session Session)

func (*DefaultCoapServer) ForwardHTTP Uses

func (s *DefaultCoapServer) ForwardHTTP(msg Message, session Session)

func (*DefaultCoapServer) Get Uses

func (s *DefaultCoapServer) Get(path string, fn RouteHandler) Route

func (*DefaultCoapServer) GetCookieSecret Uses

func (s *DefaultCoapServer) GetCookieSecret() []byte

func (*DefaultCoapServer) GetEvents Uses

func (s *DefaultCoapServer) GetEvents() Events

func (*DefaultCoapServer) GetRoutes Uses

func (s *DefaultCoapServer) GetRoutes() []Route

func (*DefaultCoapServer) GetSession Uses

func (s *DefaultCoapServer) GetSession(addr string) Session

func (*DefaultCoapServer) HandlePSK Uses

func (s *DefaultCoapServer) HandlePSK(fn func(id string) []byte)

func (*DefaultCoapServer) HasObservation Uses

func (s *DefaultCoapServer) HasObservation(resource string, addr net.Addr) bool

func (*DefaultCoapServer) ListenAndServe Uses

func (s *DefaultCoapServer) ListenAndServe(addr string)

func (*DefaultCoapServer) ListenAndServeDTLS Uses

func (s *DefaultCoapServer) ListenAndServeDTLS(addr string)

func (*DefaultCoapServer) NewRoute Uses

func (s *DefaultCoapServer) NewRoute(path string, method CoapCode, fn RouteHandler) Route

func (*DefaultCoapServer) NotifyChange Uses

func (s *DefaultCoapServer) NotifyChange(resource, value string, confirm bool)

func (*DefaultCoapServer) OnBlockMessage Uses

func (s *DefaultCoapServer) OnBlockMessage(fn FnEventBlockMessage)

func (*DefaultCoapServer) OnClose Uses

func (s *DefaultCoapServer) OnClose(fn FnEventClose)

func (*DefaultCoapServer) OnDiscover Uses

func (s *DefaultCoapServer) OnDiscover(fn FnEventDiscover)

func (*DefaultCoapServer) OnError Uses

func (s *DefaultCoapServer) OnError(fn FnEventError)

func (*DefaultCoapServer) OnMessage Uses

func (s *DefaultCoapServer) OnMessage(fn FnEventMessage)

func (*DefaultCoapServer) OnNotify Uses

func (s *DefaultCoapServer) OnNotify(fn FnEventNotify)

func (*DefaultCoapServer) OnObserve Uses

func (s *DefaultCoapServer) OnObserve(fn FnEventObserve)

func (*DefaultCoapServer) OnObserveCancel Uses

func (s *DefaultCoapServer) OnObserveCancel(fn FnEventObserveCancel)

func (*DefaultCoapServer) OnStart Uses

func (s *DefaultCoapServer) OnStart(fn FnEventStart)

func (*DefaultCoapServer) Options Uses

func (s *DefaultCoapServer) Options(path string, fn RouteHandler) Route

func (*DefaultCoapServer) Patch Uses

func (s *DefaultCoapServer) Patch(path string, fn RouteHandler) Route

func (*DefaultCoapServer) Post Uses

func (s *DefaultCoapServer) Post(path string, fn RouteHandler) Route

func (*DefaultCoapServer) ProxyOverCoap Uses

func (s *DefaultCoapServer) ProxyOverCoap(enabled bool)

func (*DefaultCoapServer) ProxyOverHttp Uses

func (s *DefaultCoapServer) ProxyOverHttp(enabled bool)

func (*DefaultCoapServer) Put Uses

func (s *DefaultCoapServer) Put(path string, fn RouteHandler) Route

func (*DefaultCoapServer) RemoveObservation Uses

func (s *DefaultCoapServer) RemoveObservation(resource string, addr net.Addr)

func (*DefaultCoapServer) SetProxyFilter Uses

func (s *DefaultCoapServer) SetProxyFilter(fn ProxyFilter)

func (*DefaultCoapServer) Stop Uses

func (s *DefaultCoapServer) Stop()

type DefaultResponse Uses

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

func (*DefaultResponse) GetError Uses

func (c *DefaultResponse) GetError() error

func (*DefaultResponse) GetMessage Uses

func (c *DefaultResponse) GetMessage() Message

func (*DefaultResponse) GetPayload Uses

func (c *DefaultResponse) GetPayload() []byte

func (*DefaultResponse) GetURIQuery Uses

func (c *DefaultResponse) GetURIQuery(q string) string

type EmptyPayload Uses

type EmptyPayload struct {
}

Represents an empty message payload

func (*EmptyPayload) GetBytes Uses

func (p *EmptyPayload) GetBytes() []byte

func (*EmptyPayload) Length Uses

func (p *EmptyPayload) Length() int

func (*EmptyPayload) String Uses

func (p *EmptyPayload) String() string

type EventCode Uses

type EventCode int
const (
    EventStart         EventCode = 0
    EventClose         EventCode = 1
    EventDiscover      EventCode = 2
    EventMessage       EventCode = 3
    EventError         EventCode = 4
    EventObserve       EventCode = 5
    EventObserveCancel EventCode = 6
    EventNotify        EventCode = 7
)

type Events Uses

type Events interface {
    OnNotify(fn FnEventNotify)
    OnStart(fn FnEventStart)
    OnClose(fn FnEventClose)
    OnDiscover(fn FnEventDiscover)
    OnError(fn FnEventError)
    OnObserve(fn FnEventObserve)
    OnObserveCancel(fn FnEventObserveCancel)
    OnMessage(fn FnEventMessage)
    OnBlockMessage(fn FnEventBlockMessage)

    Notify(resource string, value interface{}, msg Message)
    Started(server CoapServer)
    Closed(server CoapServer)
    Discover()
    Error(err error)
    Observe(resource string, msg Message)
    ObserveCancelled(resource string, msg Message)
    Message(msg Message, inbound bool)
    BlockMessage(msg Message, inbound bool)
}

type FnEventBlockMessage Uses

type FnEventBlockMessage func(Message, bool)

type FnEventClose Uses

type FnEventClose func(CoapServer)

type FnEventDiscover Uses

type FnEventDiscover func()

type FnEventError Uses

type FnEventError func(error)

type FnEventMessage Uses

type FnEventMessage func(Message, bool)

type FnEventNotify Uses

type FnEventNotify func(string, interface{}, Message)

type FnEventObserve Uses

type FnEventObserve func(string, Message)

type FnEventObserveCancel Uses

type FnEventObserveCancel func(string, Message)

type FnEventStart Uses

type FnEventStart func(CoapServer)

type JSONPayload Uses

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

Represents a message payload containing JSON String

func (*JSONPayload) GetBytes Uses

func (p *JSONPayload) GetBytes() []byte

func (*JSONPayload) Length Uses

func (p *JSONPayload) Length() int

func (*JSONPayload) String Uses

func (p *JSONPayload) String() string

type MediaType Uses

type MediaType int
const (
    MediaTypeTextPlain                  MediaType = 0
    MediaTypeTextXML                    MediaType = 1
    MediaTypeTextCsv                    MediaType = 2
    MediaTypeTextHTML                   MediaType = 3
    MediaTypeImageGif                   MediaType = 21
    MediaTypeImageJpeg                  MediaType = 22
    MediaTypeImagePng                   MediaType = 23
    MediaTypeImageTiff                  MediaType = 24
    MediaTypeAudioRaw                   MediaType = 25
    MediaTypeVideoRaw                   MediaType = 26
    MediaTypeApplicationLinkFormat      MediaType = 40
    MediaTypeApplicationXML             MediaType = 41
    MediaTypeApplicationOctetStream     MediaType = 42
    MediaTypeApplicationRdfXML          MediaType = 43
    MediaTypeApplicationSoapXML         MediaType = 44
    MediaTypeApplicationAtomXML         MediaType = 45
    MediaTypeApplicationXmppXML         MediaType = 46
    MediaTypeApplicationExi             MediaType = 47
    MediaTypeApplicationFastInfoSet     MediaType = 48
    MediaTypeApplicationSoapFastInfoSet MediaType = 49
    MediaTypeApplicationJSON            MediaType = 50
    MediaTypeApplicationXObitBinary     MediaType = 51
    MediaTypeTextPlainVndOmaLwm2m       MediaType = 1541
    MediaTypeTlvVndOmaLwm2m             MediaType = 1542
    MediaTypeJSONVndOmaLwm2m            MediaType = 1543
    MediaTypeOpaqueVndOmaLwm2m          MediaType = 1544
)

type Message Uses

type Message interface {
    GetToken() []byte
    GetMessageId() uint16
    GetMessageType() uint8
    GetAcceptedContent() MediaType
    GetCodeString() string
    GetCode() CoapCode
    GetMethod() uint8
    GetTokenLength() uint8
    GetTokenString() string
    GetOptions(id OptionCode) []Option
    GetOption(id OptionCode) Option
    GetAllOptions() []Option
    GetOptionsAsString(id OptionCode) []string
    GetLocationPath() string
    GetURIPath() string
    GetPayload() MessagePayload

    SetToken([]byte)
    SetMessageId(uint16)
    SetMessageType(uint8)
    SetBlock1Option(opt Option)
    SetStringPayload(s string)
    SetPayload(MessagePayload)

    AddOption(code OptionCode, value interface{})
    AddOptions(opts []Option)
    CloneOptions(cm Message, opts ...OptionCode)
    ReplaceOptions(code OptionCode, opts []Option)
    RemoveOptions(id OptionCode)
}

func BadGatewayMessage Uses

func BadGatewayMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 502 - Bad Gateway

func BadOptionMessage Uses

func BadOptionMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 402 - Bad Option

func BadRequestMessage Uses

func BadRequestMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 400 - Bad Request

func BytesToMessage Uses

func BytesToMessage(data []byte) (Message, error)

Converts an array of bytes to a Mesasge object. An error is returned if a parsing error occurs

func ChangedMessage Uses

func ChangedMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 204 - Changed

func ConflictMessage Uses

func ConflictMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 409 - Conflict

func ContentMessage Uses

func ContentMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 205 - Content

func ContinueMessage Uses

func ContinueMessage(messageID uint16, messageType uint8) Message

func CreatedMessage Uses

func CreatedMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 201 - Created

func DeletedMessage Uses

func DeletedMessage(messageID uint16, messageType uint8) Message

// Creates a Non-Confirmable with CoAP Code 202 - Deleted

func EmptyMessage Uses

func EmptyMessage(messageID uint16, messageType uint8) Message

Response Code Messages Creates a Non-Confirmable Empty Message

func ForbiddenMessage Uses

func ForbiddenMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 403 - Forbidden

func GatewayTimeoutMessage Uses

func GatewayTimeoutMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 504 - Gateway Timeout

func InternalServerErrorMessage Uses

func InternalServerErrorMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 500 - Internal Server Error

func MethodNotAllowedMessage Uses

func MethodNotAllowedMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 405 - Method Not Allowed

func NewEmptyMessage Uses

func NewEmptyMessage(id uint16) Message

Instantiates an empty message with a given message id

func NewMessage Uses

func NewMessage(messageType uint8, code CoapCode, messageID uint16) Message

Instantiates a new message object messageType (e.g. Confirm/Non-Confirm) CoAP code 404 - Not found etc Message ID uint16 unique id

func NewMessageOfType Uses

func NewMessageOfType(t uint8, id uint16, payload MessagePayload) Message

Instantiates an empty message of a specific type and message id

func NotAcceptableMessage Uses

func NotAcceptableMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 406 - Not Acceptable

func NotFoundMessage Uses

func NotFoundMessage(messageID uint16, messageType uint8, token []byte) (m Message)

Creates a Non-Confirmable with CoAP Code 404 - Not Found

func NotImplementedMessage Uses

func NotImplementedMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 501 - Not Implemented

func PreconditionFailedMessage Uses

func PreconditionFailedMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 412 - Precondition Failed

func ProxyingNotSupportedMessage Uses

func ProxyingNotSupportedMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 505 - Proxying Not Supported

func RequestEntityTooLargeMessage Uses

func RequestEntityTooLargeMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 413 - Request Entity Too Large

func ServiceUnavailableMessage Uses

func ServiceUnavailableMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 503 - Service Unavailable

func UnauthorizedMessage Uses

func UnauthorizedMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 401 - Unauthorized

func UnsupportedContentFormatMessage Uses

func UnsupportedContentFormatMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 415 - Unsupported Content Format

func ValidMessage Uses

func ValidMessage(messageID uint16, messageType uint8) Message

Creates a Non-Confirmable with CoAP Code 203 - Valid

type MessagePayload Uses

type MessagePayload interface {
    GetBytes() []byte
    Length() int
    String() string
}

Represents the payload/content of a CoAP Message

func NewBytesPayload Uses

func NewBytesPayload(v []byte) MessagePayload

Represents a message payload containing an array of bytes

func NewEmptyPayload Uses

func NewEmptyPayload() MessagePayload

func NewJSONPayload Uses

func NewJSONPayload(obj interface{}) MessagePayload

func NewPlainTextPayload Uses

func NewPlainTextPayload(s string) MessagePayload

Instantiates a new message payload of type string

type NilResponse Uses

type NilResponse struct {
}

func (NilResponse) GetError Uses

func (c NilResponse) GetError() error

func (NilResponse) GetMessage Uses

func (c NilResponse) GetMessage() Message

func (NilResponse) GetPayload Uses

func (c NilResponse) GetPayload() []byte

func (NilResponse) GetURIQuery Uses

func (c NilResponse) GetURIQuery(q string) string

type Observation Uses

type Observation struct {
    Session     Session
    Token       string
    Resource    string
    NotifyCount int
}

func NewObservation Uses

func NewObservation(session Session, token string, resource string) *Observation

type ObserveMessage Uses

type ObserveMessage interface {
    GetResource() string
    GetValue() interface{}
    GetMessage() Message
}

func NewObserveMessage Uses

func NewObserveMessage(r string, val interface{}, msg Message) ObserveMessage

type Option Uses

type Option interface {
    Name() string
    IsElective() bool
    IsCritical() bool
    StringValue() string
    IntValue() int
    GetCode() OptionCode
    GetValue() interface{}
}

func NewPathOptions Uses

func NewPathOptions(path string) []Option

Creates an array of options decomposed from a given path

type OptionCode Uses

type OptionCode int

OptionCode type represents a valid CoAP Option Code

const (
    // OptionIfMatch request-header field is used with a method to make it conditional.
    // A client that has one or more entities previously obtained from the resource can verify
    // that one of those entities is current by including a list of their associated entity tags
    // in the If-Match header field.
    OptionIfMatch OptionCode = 1

    OptionURIHost       OptionCode = 3
    OptionEtag          OptionCode = 4
    OptionIfNoneMatch   OptionCode = 5
    OptionObserve       OptionCode = 6
    OptionURIPort       OptionCode = 7
    OptionLocationPath  OptionCode = 8
    OptionURIPath       OptionCode = 11
    OptionContentFormat OptionCode = 12
    OptionMaxAge        OptionCode = 14
    OptionURIQuery      OptionCode = 15
    OptionAccept        OptionCode = 17
    OptionLocationQuery OptionCode = 20
    OptionBlock2        OptionCode = 23
    OptionBlock1        OptionCode = 27
    OptionSize2         OptionCode = 28
    OptionProxyURI      OptionCode = 35
    OptionProxyScheme   OptionCode = 39
    OptionSize1         OptionCode = 60
)

type PlainTextPayload Uses

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

Represents a message payload containing string value

func (*PlainTextPayload) GetBytes Uses

func (p *PlainTextPayload) GetBytes() []byte

func (*PlainTextPayload) Length Uses

func (p *PlainTextPayload) Length() int

func (*PlainTextPayload) String Uses

func (p *PlainTextPayload) String() string

type ProxyFilter Uses

type ProxyFilter func(Message, net.Addr) bool

Proxy Filter

type ProxyHandler Uses

type ProxyHandler func(c CoapServer, msg Message, session Session)

type RegExRoute Uses

type RegExRoute struct {
    Path       string
    Method     string
    Handler    RouteHandler
    RegEx      *regexp.Regexp
    AutoAck    bool
    MediaTypes []MediaType
}

Route represents a CoAP Route/Resource

func (*RegExRoute) AutoAcknowledge Uses

func (r *RegExRoute) AutoAcknowledge() bool

func (*RegExRoute) GetConfiguredPath Uses

func (r *RegExRoute) GetConfiguredPath() string

func (*RegExRoute) GetMediaTypes Uses

func (r *RegExRoute) GetMediaTypes() []MediaType

func (*RegExRoute) GetMethod Uses

func (r *RegExRoute) GetMethod() string

func (*RegExRoute) Handle Uses

func (r *RegExRoute) Handle(req Request) Response

func (*RegExRoute) Matches Uses

func (r *RegExRoute) Matches(path string) (bool, map[string]string)

type Request Uses

type Request interface {
    GetAttributes() map[string]string
    GetAttribute(o string) string
    GetAttributeAsInt(o string) int
    GetMessage() Message
    GetURIQuery(q string) string

    SetProxyURI(uri string)
    SetMediaType(mt MediaType)
    SetPayload([]byte)
    SetStringPayload(s string)
    SetRequestURI(uri string)
    SetConfirmable(con bool)
    SetToken(t string)
    SetURIQuery(k string, v string)
}

func NewClientRequestFromMessage Uses

func NewClientRequestFromMessage(msg Message, attrs map[string]string, session Session) Request

func NewConfirmableDeleteRequest Uses

func NewConfirmableDeleteRequest() Request

func NewConfirmableGetRequest Uses

func NewConfirmableGetRequest() Request

func NewConfirmablePostRequest Uses

func NewConfirmablePostRequest() Request

func NewConfirmablePutRequest Uses

func NewConfirmablePutRequest() Request

func NewRequest Uses

func NewRequest(messageType uint8, messageMethod CoapCode) Request

Creates a New Request Instance

func NewRequestFromMessage Uses

func NewRequestFromMessage(msg Message) Request

Creates a new request messages from a CoAP Message

func NewRequestWithMessageId Uses

func NewRequestWithMessageId(messageType uint8, messageMethod CoapCode, messageID uint16) Request

type Response Uses

type Response interface {
    GetMessage() Message
    GetError() error
    GetPayload() []byte
    GetURIQuery(q string) string
}

func NewResponse Uses

func NewResponse(msg Message, err error) Response

Creates a new Response object with a Message object and any error messages

func NewResponseWithMessage Uses

func NewResponseWithMessage(msg Message) Response

Creates a new response object with a Message object

func NoResponse Uses

func NoResponse() Response

func SendMessage Uses

func SendMessage(msg Message, session Session) (Response, error)

type Route Uses

type Route interface {
    GetMethod() string
    GetMediaTypes() []MediaType
    GetConfiguredPath() string

    Matches(path string) (bool, map[string]string)
    AutoAcknowledge() bool
    Handle(req Request) Response
}

func CreateNewRegExRoute Uses

func CreateNewRegExRoute(path string, method string, fn RouteHandler) Route

CreateNewRoute creates a new Route object

func MatchingRoute Uses

func MatchingRoute(path string, method string, cf interface{}, routes []Route) (Route, map[string]string, error)

MatchingRoute checks if a given path matches any defined routes/resources

type RouteHandler Uses

type RouteHandler func(Request) Response

type ServerConfiguration Uses

type ServerConfiguration struct {
    EnableResourceDiscovery bool
}

type ServerConnection Uses

type ServerConnection interface {
    ReadFrom(b []byte) (n int, addr net.Addr, err error)
    WriteTo(b []byte, addr net.Addr) (n int, err error)
    Close() error
    LocalAddr() net.Addr
    SetDeadline(t time.Time) error
    SetReadDeadline(t time.Time) error
    SetWriteDeadline(t time.Time) error
}

type ServerDtlsContext Uses

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

func NewServerDtlsContext Uses

func NewServerDtlsContext() (ctx *ServerDtlsContext, err error)

type ServerEvents Uses

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

This holds the various events which are triggered throughout an application's lifetime

func NewEvents Uses

func NewEvents() *ServerEvents

func (*ServerEvents) BlockMessage Uses

func (ce *ServerEvents) BlockMessage(msg Message, inbound bool)

Fires the "OnBlockMessage" event. The 'inbound' variables determines if the message is inbound or outgoing

func (*ServerEvents) Closed Uses

func (ce *ServerEvents) Closed(server CoapServer)

Fires the "OnClosed" event

func (*ServerEvents) Discover Uses

func (ce *ServerEvents) Discover()

Fires the "OnDiscover" event

func (*ServerEvents) Error Uses

func (ce *ServerEvents) Error(err error)

Fires the "OnError" event given an error object

func (*ServerEvents) Message Uses

func (ce *ServerEvents) Message(msg Message, inbound bool)

Fires the "OnMessage" event. The 'inbound' variables determines if the message is inbound or outgoing

func (*ServerEvents) Notify Uses

func (ce *ServerEvents) Notify(resource string, value interface{}, msg Message)

Fires the "OnNotify" event

func (*ServerEvents) Observe Uses

func (ce *ServerEvents) Observe(resource string, msg Message)

Fires the "OnObserve" event for a given resource

func (*ServerEvents) ObserveCancelled Uses

func (ce *ServerEvents) ObserveCancelled(resource string, msg Message)

Fires the "OnObserveCancelled" event for a given resource

func (*ServerEvents) OnBlockMessage Uses

func (ce *ServerEvents) OnBlockMessage(fn FnEventBlockMessage)

Fired when a block messageis received

func (*ServerEvents) OnClose Uses

func (ce *ServerEvents) OnClose(fn FnEventClose)

Fired when the server/client closes

func (*ServerEvents) OnDiscover Uses

func (ce *ServerEvents) OnDiscover(fn FnEventDiscover)

Fired when a discovery request is triggered

func (*ServerEvents) OnError Uses

func (ce *ServerEvents) OnError(fn FnEventError)

Catch-all event which is fired when an error occurs

func (*ServerEvents) OnMessage Uses

func (ce *ServerEvents) OnMessage(fn FnEventMessage)

Fired when a message is received

func (*ServerEvents) OnNotify Uses

func (ce *ServerEvents) OnNotify(fn FnEventNotify)

OnNotify is Fired when an observeed resource is notified

func (*ServerEvents) OnObserve Uses

func (ce *ServerEvents) OnObserve(fn FnEventObserve)

Fired when an observe request is triggered for a resource

func (*ServerEvents) OnObserveCancel Uses

func (ce *ServerEvents) OnObserveCancel(fn FnEventObserveCancel)

Fired when an observe-cancel request is triggered foa r esource

func (*ServerEvents) OnStart Uses

func (ce *ServerEvents) OnStart(fn FnEventStart)

Fired when the server/client starts up

func (*ServerEvents) Started Uses

func (ce *ServerEvents) Started(server CoapServer)

Fires the "OnStarted" event

type Session Uses

type Session interface {
    GetConnection() ServerConnection
    GetAddress() net.Addr
    Write([]byte) (int, error)
    Read([]byte) (n int, err error)
    GetServer() CoapServer
    WriteBuffer([]byte) int
}

type SortOptions Uses

type SortOptions []Option

type to sort the coap options list (which is mandatory) prior to transmission

func (SortOptions) Len Uses

func (opts SortOptions) Len() int

func (SortOptions) Less Uses

func (opts SortOptions) Less(i, j int) bool

func (SortOptions) Swap Uses

func (opts SortOptions) Swap(i, j int)

type UDPConnection Uses

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

func (*UDPConnection) CancelObserveResource Uses

func (c *UDPConnection) CancelObserveResource(resource string, token string) (err error)

func (*UDPConnection) Close Uses

func (c *UDPConnection) Close() error

func (*UDPConnection) Observe Uses

func (c *UDPConnection) Observe(ch chan ObserveMessage)

func (*UDPConnection) ObserveResource Uses

func (c *UDPConnection) ObserveResource(resource string) (tok string, err error)

func (*UDPConnection) Read Uses

func (c *UDPConnection) Read(b []byte) (int, error)

func (*UDPConnection) Send Uses

func (c *UDPConnection) Send(req Request) (resp Response, err error)

func (*UDPConnection) SendMessage Uses

func (c *UDPConnection) SendMessage(msg Message) (resp Response, err error)

func (*UDPConnection) StopObserve Uses

func (c *UDPConnection) StopObserve(ch chan ObserveMessage)

func (*UDPConnection) Write Uses

func (c *UDPConnection) Write(b []byte) (int, error)

type UDPServerConnection Uses

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

func (*UDPServerConnection) Close Uses

func (uc *UDPServerConnection) Close() error

func (*UDPServerConnection) LocalAddr Uses

func (uc *UDPServerConnection) LocalAddr() net.Addr

func (*UDPServerConnection) ReadFrom Uses

func (uc *UDPServerConnection) ReadFrom(b []byte) (n int, addr net.Addr, err error)

func (*UDPServerConnection) SetDeadline Uses

func (uc *UDPServerConnection) SetDeadline(t time.Time) error

func (*UDPServerConnection) SetReadDeadline Uses

func (uc *UDPServerConnection) SetReadDeadline(t time.Time) error

func (*UDPServerConnection) SetWriteDeadline Uses

func (uc *UDPServerConnection) SetWriteDeadline(t time.Time) error

func (*UDPServerConnection) WriteTo Uses

func (uc *UDPServerConnection) WriteTo(b []byte, addr net.Addr) (n int, err error)

type UDPServerSession Uses

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

func (*UDPServerSession) GetAddress Uses

func (s *UDPServerSession) GetAddress() net.Addr

func (*UDPServerSession) GetConnection Uses

func (s *UDPServerSession) GetConnection() ServerConnection

func (*UDPServerSession) GetServer Uses

func (s *UDPServerSession) GetServer() CoapServer

func (*UDPServerSession) Read Uses

func (s *UDPServerSession) Read(b []byte) (n int, err error)

func (*UDPServerSession) Write Uses

func (s *UDPServerSession) Write(b []byte) (n int, err error)

func (*UDPServerSession) WriteBuffer Uses

func (s *UDPServerSession) WriteBuffer(b []byte) (n int)

type XMLPayload Uses

type XMLPayload struct {
}

Represents a message payload containing XML String

Package canopus imports 27 packages (graph) and is imported by 4 packages. Updated 2018-02-07. Refresh now. Tools for package owners.