diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2022-11-08 22:48:20 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-16 21:39:39 +0300 |
| commit | 833a46544df2ed2a7afdba08ebfe02ed7741d86a (patch) | |
| tree | 2432f14b449761086d773fb8cd072797d23006f1 /packets/messages/types/SvcClassInfo.go | |
| parent | put class type into individual files (diff) | |
| download | sdp.go-833a46544df2ed2a7afdba08ebfe02ed7741d86a.tar.gz sdp.go-833a46544df2ed2a7afdba08ebfe02ed7741d86a.tar.bz2 sdp.go-833a46544df2ed2a7afdba08ebfe02ed7741d86a.zip | |
net/svc messages
Diffstat (limited to 'packets/messages/types/SvcClassInfo.go')
| -rw-r--r-- | packets/messages/types/SvcClassInfo.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/packets/messages/types/SvcClassInfo.go b/packets/messages/types/SvcClassInfo.go new file mode 100644 index 0000000..58e43b7 --- /dev/null +++ b/packets/messages/types/SvcClassInfo.go | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | package types | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "math" | ||
| 5 | |||
| 6 | "github.com/pektezol/bitreader" | ||
| 7 | ) | ||
| 8 | |||
| 9 | type SvcClassInfo struct { | ||
| 10 | Length uint16 | ||
| 11 | CreateOnClient bool | ||
| 12 | ServerClasses []ServerClass | ||
| 13 | } | ||
| 14 | |||
| 15 | type ServerClass struct { | ||
| 16 | ClassId int32 | ||
| 17 | ClassName string | ||
| 18 | DataTableName string | ||
| 19 | } | ||
| 20 | |||
| 21 | func ParseSvcClassInfo(reader *bitreader.ReaderType) SvcClassInfo { | ||
| 22 | var serverclasses []ServerClass | ||
| 23 | svcclassinfo := SvcClassInfo{ | ||
| 24 | Length: reader.TryReadInt16(), | ||
| 25 | CreateOnClient: reader.TryReadBool(), | ||
| 26 | } | ||
| 27 | if svcclassinfo.CreateOnClient { | ||
| 28 | for i := 0; i < int(svcclassinfo.Length); i++ { | ||
| 29 | id, err := reader.ReadBits(int(math.Log2(float64(svcclassinfo.Length))) + 1) | ||
| 30 | if err != nil { | ||
| 31 | panic(err) | ||
| 32 | } | ||
| 33 | serverclasses = append(serverclasses, ServerClass{ | ||
| 34 | ClassId: int32(id), | ||
| 35 | ClassName: reader.TryReadString(), | ||
| 36 | DataTableName: reader.TryReadString(), | ||
| 37 | }) | ||
| 38 | } | ||
| 39 | } | ||
| 40 | svcclassinfo.ServerClasses = serverclasses | ||
| 41 | return svcclassinfo | ||
| 42 | } | ||