Comments (11)
Can you paste the struct or at least the field? I was looking at the reflect tests and realised we don't actually have a test for time.Time
although it should be supported. Perhaps you can try *AVP
?
from go-diameter.
sure so this is my struct I am trying to use (or a part of it anyway). I will give *AVP
a shot to see what happens.
type ccr struct {
EventTimestamp time.Time `avp:"Event-Timestamp"`
SessionID string `avp:"Session-Id"`
OriginHost string `avp:"Origin-Host"`
OriginRealm string `avp:"Origin-Realm"`
DestinationRealm string `avp:"Destination-Realm"`
AuthApplicationID int32 `avp:"Auth-Application-Id"`
ServiceContextID string `avp:"Service-Context-Id"`
CCRequestType int32 `avp:"CC-Request-Type"`
CCRequestNumber int32 `avp:"CC-Request-Number"`
DestinationHost string `avp:"Destination-Host"`
}
from go-diameter.
That's what I suspected. So, try first changing from time.Time
to datatype.Time
and you should get the right value. I believe we don't have the right conversion from AVP to time.Time
in reflect.go
. You could probably add that, and a unit test.
from go-diameter.
actually I had tried datatype.Time
and it gives me the same result
from go-diameter.
type ccr struct {
EventTimestamp datatype.Time `avp:"Event-Timestamp"`
SessionID string `avp:"Session-Id"`
OriginHost string `avp:"Origin-Host"`
OriginRealm string `avp:"Origin-Realm"`
DestinationRealm string `avp:"Destination-Realm"`
AuthApplicationID int32 `avp:"Auth-Application-Id"`
ServiceContextID string `avp:"Service-Context-Id"`
CCRequestType int32 `avp:"CC-Request-Type"`
CCRequestNumber int32 `avp:"CC-Request-Number"`
DestinationHost string `avp:"Destination-Host"`
}
Results in
Time{0001-01-01 00:00:00 +0000 UTC}
Time{0001-01-01 00:00:00 +0000 UTC}
Time{0001-01-01 00:00:00 +0000 UTC}
Time{0001-01-01 00:00:00 +0000 UTC}
Time{0001-01-01 00:00:00 +0000 UTC}
Time{0001-01-01 00:00:00 +0000 UTC}
Time{0001-01-01 00:00:00 +0000 UTC}
Time{0001-01-01 00:00:00 +0000 UTC}
Where as manually using msg.FindAVP(avp.EventTimestamp, 0)
comes out with the following
Time{2016-02-27 17:23:16 -0600 CST}
Time{2016-02-27 17:23:16 -0600 CST}
Time{2016-02-27 17:23:16 -0600 CST}
Time{2016-02-27 17:23:16 -0600 CST}
Time{2016-02-27 17:23:16 -0600 CST}
from go-diameter.
Right, so something messed up in reflect.go
. We should definitely have a test for that.
from go-diameter.
I have added test as follows (not sure yet how to fix reflect.go):
func TestUnmarshalTimeDatatype(t *testing.T) {
expectedTime := "Time{2015-12-09 16:40:53 +0100 CET}"
m, _ := ReadMessage(bytes.NewReader(testMessageWithVendorID), dict.Default)
type Data struct {
EventTimestamp datatype.Time `avp:"Event-Timestamp"`
}
var d Data
if err := m.Unmarshal(&d); err != nil {
t.Fatal(err)
}
if d.EventTimestamp.String() != expectedTime {
t.Fatalf("Unexpected value, want %s, have %s", expectedTime, d.EventTimestamp.String())
}
}
from go-diameter.
In order to fix reflect.go we have to look for the avp name in the field tag, ensure that the field is a time field in the dictionary, then decide what to do based on the field type. It already supports AVP
and *AVP
but does not support datatype.Time
and time.Time
.
from go-diameter.
@fiorix / @DefunctExodus - should this one be closed by #66? Or is there something else to be done?
from go-diameter.
I believe so
from go-diameter.
This can be closed now, Sorry I have not had a ton of time to play with it lately
from go-diameter.
Related Issues (20)
- Does the 'Getting Started' instructions on Readme.md need update ? HOT 2
- Missing DeleteAVP functionality HOT 1
- CCR
- how to avoid dict.Default
- Empty AVP Payload causes crash
- Dangling AVP references in readerBufferPool
- How to parse AVP sub attributes ?
- unmarshal issue when two avp's with same id but different VendorId used
- diam_sctp_client is crashing on connection
- Make certificates optional in ListenAndServeTLS to allow an external callback
- server closes the connection HOT 3
- Performance on sctp is very poor
- Any way to leverage the XML to validate produced messages?
- Missing Handshake Notifications in channel
- multi-homing HOT 1
- One Client dials to Multiple Server HOT 2
- Close listening socket
- Diameter Client receving CCA HOT 3
- CCA Handler HOT 1
- CER/CEA remote peer validation HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-diameter.