Support keepalive PING messages on the socket

This commit is contained in:
Gabe Kangas
2020-06-14 16:44:38 -07:00
parent a3c3276a48
commit a9662e7c1e
6 changed files with 92 additions and 32 deletions

View File

@@ -1,12 +1,25 @@
package main
type Message struct {
Author string `json:"author"`
Body string `json:"body"`
Image string `json:"image"`
Id string `json:"id"`
type ChatMessage struct {
Author string `json:"author"`
Body string `json:"body"`
Image string `json:"image"`
ID string `json:"id"`
MessageType string `json:"type"`
}
func (self *Message) String() string {
return self.Author + " says " + self.Body
func (s *ChatMessage) AsJson() string {
return s.Author + " says " + s.Body
}
func (s *ChatMessage) String() string {
return s.Author + " says " + s.Body
}
type PingMessage struct {
MessageType string `json:"type"`
}
func (self *PingMessage) AsJson() string {
return "{type: \"PING\"}"
}