github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/tcp/socket-codec.go (about) 1 /* For license and copyright information please see LEGAL file in repository */ 2 3 package tcp 4 5 import ( 6 "../protocol" 7 ) 8 9 /* 10 ********** protocol.Codec interface ********** 11 */ 12 13 func (s *Socket) MediaType() protocol.MediaType { return nil } 14 func (s *Socket) CompressType() protocol.CompressType { return nil } 15 16 func (s *Socket) Decode(reader protocol.Reader) (err protocol.Error) { return } 17 func (s *Socket) Encode(writer protocol.Writer) (err protocol.Error) { 18 var _, goErr = s.WriteTo(writer) 19 if goErr != nil { 20 // err = 21 } 22 return 23 } 24 func (s *Socket) Marshal() (data []byte) { 25 if !s.recv.buf.Full() { 26 select { 27 case <-s.readDeadline.C: 28 break 29 case <-s.recv.pushFlag: 30 break 31 } 32 } 33 return s.recv.buf.Marshal() 34 } 35 func (s *Socket) MarshalTo(data []byte) []byte { 36 // TODO::: check buffer and return 37 // TODO::: listen to state channel and return when data ready 38 return s.recv.buf.Marshal(data) 39 } 40 func (s *Socket) Unmarshal(data []byte) (err protocol.Error) { return } 41 func (s *Socket) UnmarshalFrom(data []byte) (remaining []byte, err protocol.Error) { 42 return 43 } 44 func (s *Socket) Len() (ln int) { return }