當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Message.Unmarshal方法代碼示例

本文整理匯總了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
}
開發者ID:bhepp,項目名稱:cgrates,代碼行數:10,代碼來源:libdmt.go

示例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
}
開發者ID:Gladmir,項目名稱:go-diameter,代碼行數:12,代碼來源:dwr.go

示例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
}
開發者ID:Gladmir,項目名稱:go-diameter,代碼行數:19,代碼來源:cea.go

示例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
}
開發者ID:aSimpleboy,項目名稱:go-diameter,代碼行數:31,代碼來源:cer.go

示例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
}
開發者ID:Gladmir,項目名稱:go-diameter,代碼行數:7,代碼來源:dwa.go


注:本文中的github.com/fiorix/go-diameter/diam.Message.Unmarshal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。