Support keepalive PING messages on the socket
This commit is contained in:
27
message.go
27
message.go
@@ -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\"}"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user