lcfile.go 944 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package protocol
  2. type FileObject struct {
  3. File string `json:"file"`
  4. Content string `json:"content"`
  5. }
  6. type Pack_SeqFileObject struct {
  7. Header
  8. Data FileObject `json:"data"`
  9. }
  10. func (o *Pack_SeqFileObject) EnCode(gid string, seq uint64) (string, error) {
  11. o.Header.SetHeaderData(gid, gid, seq)
  12. return json.MarshalToString(o)
  13. }
  14. func (o *Pack_SeqFileObject) DeCode(msg string) error {
  15. var obj Pack_SeqFileObject
  16. if err := json.UnmarshalFromString(msg, &obj); err != nil {
  17. return err
  18. }
  19. *o = obj
  20. return nil
  21. }
  22. type MutilFileObject struct {
  23. Files []FileObject `json:"files,omitempty"`
  24. }
  25. type Pack_MutilFileObject struct {
  26. Header
  27. Data MutilFileObject `json:"data"`
  28. }
  29. func (o *Pack_MutilFileObject) EnCode(gid string, seq uint64) (string, error) {
  30. o.Header.SetHeaderData(gid, gid, seq)
  31. return json.MarshalToString(o)
  32. }
  33. func (o *Pack_MutilFileObject) DeCode(message string) error {
  34. return json.UnmarshalFromString(message, o)
  35. }