Add "String" methods to ClientMessage/ServerMessage.

This commit is contained in:
Joachim Bauch 2021-06-07 16:31:19 +02:00
parent c8886d03c9
commit 447fa9a279
No known key found for this signature in database
GPG Key ID: 77C1D22D53E15F02
1 changed files with 16 additions and 0 deletions

View File

@ -95,6 +95,14 @@ func (m *ClientMessage) CheckValid() error {
return nil
}
func (m *ClientMessage) String() string {
data, err := json.Marshal(m)
if err != nil {
return fmt.Sprintf("Could not serialize %#v: %s", m, err)
}
return string(data)
}
func (m *ClientMessage) NewErrorServerMessage(e *Error) *ServerMessage {
return &ServerMessage{
Id: m.Id,
@ -179,6 +187,14 @@ func (r *ServerMessage) IsParticipantsUpdate() bool {
return true
}
func (r *ServerMessage) String() string {
data, err := json.Marshal(r)
if err != nil {
return fmt.Sprintf("Could not serialize %#v: %s", r, err)
}
return string(data)
}
type Error struct {
Code string `json:"code"`
Message string `json:"message"`