本文整理匯總了Golang中github.com/fiorix/go-diameter/diam.Message.Unmarshal方法的典型用法代碼示例。如果您正苦於以下問題:Golang Message.Unmarshal方法的具體用法?Golang Message.Unmarshal怎麽用?Golang Message.Unmarshal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/fiorix/go-diameter/diam.Message
的用法示例。
在下文中一共展示了Message.Unmarshal方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewCCRFromDiameterMessage
// debitInterval is the configured debitInterval, in sync with the diameter client one
func NewCCRFromDiameterMessage(m *diam.Message, debitInterval time.Duration) (*CCR, error) {
var ccr CCR
if err := m.Unmarshal(&ccr); err != nil {
return nil, err
}
ccr.diamMessage = m
ccr.debitInterval = debitInterval
return &ccr, nil
}
示例2: Parse
// Parse parses and validates the given message, and returns nil when
// all AVPs are ok.
func (dwr *DWR) Parse(m *diam.Message) error {
err := m.Unmarshal(dwr)
if err != nil {
return nil
}
if err = dwr.sanityCheck(); err != nil {
return err
}
return nil
}
示例3: Parse
// Parse parses and validates the given message.
func (cea *CEA) Parse(m *diam.Message) (err error) {
if err = m.Unmarshal(cea); err != nil {
return err
}
if err = cea.sanityCheck(); err != nil {
return err
}
app := &Application{
AcctApplicationID: cea.AcctApplicationID,
AuthApplicationID: cea.AuthApplicationID,
VendorSpecificApplicationID: cea.VendorSpecificApplicationID,
}
if _, err := app.Parse(m.Dictionary()); err != nil {
return err
}
cea.appID = app.ID()
return nil
}
示例4: Parse
// Parse parses and validates the given message, and returns nil when
// all AVPs are ok, and all accounting or authentication applications
// in the CER match the applications in our dictionary. If one or more
// mandatory AVPs are missing, it returns a nil failedAVP and a proper
// error. If all mandatory AVPs are present but no common application
// is found, then it returns the failedAVP (with the application that
// we don't support in our dictionary) and an error. Another cause
// for error is the presence of Inband Security, we don't support that.
func (cer *CER) Parse(m *diam.Message) (failedAVP *diam.AVP, err error) {
if err = m.Unmarshal(cer); err != nil {
return nil, err
}
if err = cer.sanityCheck(); err != nil {
return nil, err
}
if cer.InbandSecurityID != nil {
if v := cer.InbandSecurityID.Data.(datatype.Unsigned32); v != 0 {
return cer.InbandSecurityID, ErrNoCommonSecurity
}
}
app := &Application{
AcctApplicationID: cer.AcctApplicationID,
AuthApplicationID: cer.AuthApplicationID,
VendorSpecificApplicationID: cer.VendorSpecificApplicationID,
}
if failedAVP, err = app.Parse(m.Dictionary()); err != nil {
return failedAVP, err
}
cer.appID = app.ID()
return nil, nil
}
示例5: Parse
// Parse parses the given message.
func (dwa *DWA) Parse(m *diam.Message) error {
if err := m.Unmarshal(dwa); err != nil {
return err
}
return nil
}