package protocol

type FileObject struct {
	File    string `json:"file"`
	Content string `json:"content"`
}

type Pack_SeqFileObject struct {
	Header
	Data FileObject `json:"data"`
}

func (o *Pack_SeqFileObject) EnCode(gid string, seq uint64) (string, error) {
	o.Header.SetHeaderData(gid, gid, seq)
	return json.MarshalToString(o)
}

func (o *Pack_SeqFileObject) DeCode(msg string) error {
	var obj Pack_SeqFileObject
	if err := json.UnmarshalFromString(msg, &obj); err != nil {
		return err
	}
	*o = obj
	return nil
}

type MutilFileObject struct {
	Files []FileObject `json:"files,omitempty"`
}
type Pack_MutilFileObject struct {
	Header
	Data MutilFileObject `json:"data"`
}

func (o *Pack_MutilFileObject) EnCode(gid string, seq uint64) (string, error) {
	o.Header.SetHeaderData(gid, gid, seq)
	return json.MarshalToString(o)
}

func (o *Pack_MutilFileObject) DeCode(message string) error {
	return json.UnmarshalFromString(message, o)
}
