diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-12 20:53:09 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-16 21:39:42 +0300 |
| commit | 82871ba1bac1d62f69e1933b66659e62d2e5e063 (patch) | |
| tree | a906310fba89b670bcfda9625a6d776553d482f6 /pkg/messages/types/svcClassInfo.go | |
| parent | net/svc messages finally getting parsed correctly (diff) | |
| download | sdp.go-82871ba1bac1d62f69e1933b66659e62d2e5e063.tar.gz sdp.go-82871ba1bac1d62f69e1933b66659e62d2e5e063.tar.bz2 sdp.go-82871ba1bac1d62f69e1933b66659e62d2e5e063.zip | |
another rewrite, v1.0.0
Diffstat (limited to 'pkg/messages/types/svcClassInfo.go')
| -rw-r--r-- | pkg/messages/types/svcClassInfo.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/pkg/messages/types/svcClassInfo.go b/pkg/messages/types/svcClassInfo.go new file mode 100644 index 0000000..9f367d3 --- /dev/null +++ b/pkg/messages/types/svcClassInfo.go | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | package messages | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "fmt" | ||
| 5 | "math" | ||
| 6 | |||
| 7 | "github.com/pektezol/bitreader" | ||
| 8 | ) | ||
| 9 | |||
| 10 | type SvcClassInfo struct { | ||
| 11 | Length int16 | ||
| 12 | CreateOnClient bool | ||
| 13 | ServerClasses []serverClass | ||
| 14 | } | ||
| 15 | |||
| 16 | type serverClass struct { | ||
| 17 | ClassId int16 | ||
| 18 | ClassName string | ||
| 19 | DataTableName string | ||
| 20 | } | ||
| 21 | |||
| 22 | func ParseSvcClassInfo(reader *bitreader.ReaderType) SvcClassInfo { | ||
| 23 | svcClassInfo := SvcClassInfo{ | ||
| 24 | Length: int16(reader.TryReadBits(16)), | ||
| 25 | CreateOnClient: reader.TryReadBool(), | ||
| 26 | } | ||
| 27 | classes := []serverClass{} | ||
| 28 | if !svcClassInfo.CreateOnClient { | ||
| 29 | for count := 0; count < int(svcClassInfo.Length); count++ { | ||
| 30 | fmt.Println(classes) | ||
| 31 | classes = append(classes, serverClass{ | ||
| 32 | ClassId: int16(reader.TryReadBits(int(math.Log2(float64(svcClassInfo.Length)) + 1))), | ||
| 33 | ClassName: reader.TryReadString(), | ||
| 34 | DataTableName: reader.TryReadString(), | ||
| 35 | }) | ||
| 36 | } | ||
| 37 | } | ||
| 38 | svcClassInfo.ServerClasses = classes | ||
| 39 | return svcClassInfo | ||
| 40 | } | ||