github.com/anycable/anycable-go@v1.5.1/encoders/encoder.go (about)

     1  package encoders
     2  
     3  import (
     4  	"github.com/anycable/anycable-go/common"
     5  	"github.com/anycable/anycable-go/ws"
     6  )
     7  
     8  type EncodedMessage interface {
     9  	GetType() string
    10  }
    11  
    12  var _ EncodedMessage = (*common.Reply)(nil)
    13  var _ EncodedMessage = (*common.PingMessage)(nil)
    14  var _ EncodedMessage = (*common.DisconnectMessage)(nil)
    15  
    16  type Encoder interface {
    17  	ID() string
    18  	Encode(msg EncodedMessage) (*ws.SentFrame, error)
    19  	EncodeTransmission(msg string) (*ws.SentFrame, error)
    20  	Decode(payload []byte) (*common.Message, error)
    21  }
    22  
    23  var _ Encoder = (*JSON)(nil)