Files
stun/attribute_software.go
2017-02-11 05:23:49 +03:00

32 lines
584 B
Go

package stun
// Software is SOFTWARE attribute.
type Software struct {
Raw []byte
}
func (s *Software) String() string {
return string(s.Raw)
}
// NewSoftware returns *Software from string.
func NewSoftware(software string) *Software {
return &Software{Raw: []byte(software)}
}
// AddTo adds Software attribute to m.
func (s *Software) AddTo(m *Message) error {
m.Add(AttrSoftware, m.Raw)
return nil
}
// GetFrom decodes Software from m.
func (s *Software) GetFrom(m *Message) error {
v, err := m.Get(AttrSoftware)
if err != nil {
return err
}
s.Raw = v
return nil
}