messages=append(messages,models.ChatMessage{"Blathers","Blathers is an owl with brown feathers. His face is white and he has a yellow beak. His arms are wing shaped and he has yellow talons. His eyes are very big with small black irises. He also has big pink cheek circles on his cheeks. His belly appears to be checkered in diamonds with light brown and white squares, similar to an argyle vest, which is traditionally associated with academia. His green bowtie further alludes to his academic nature.","https://vignette.wikia.nocookie.net/animalcrossing/images/b/b3/NH-character-Blathers.png/revision/latest?cb=20200229053519","demo-message-6","ChatMessage"})
server:=&Server{
pattern,
messages,
clients,
"/entry",//hardcoded due to the UI requiring this and it is not configurable
addCh,
delCh,
sendAllCh,
@ -116,26 +116,27 @@ func (s *Server) ping() {
@@ -116,26 +116,27 @@ func (s *Server) ping() {
}
}
func(s*Server)onConnection(ws*websocket.Conn){
client:=NewClient(ws,s)
deferfunc(){
log.Printf("The client was connected for %s and sent %d messages (%s)",time.Since(client.ConnectedAt),client.MessageCount,client.id)
iferr:=ws.Close();err!=nil{
s.errCh<-err
}
}()
s.Add(client)
client.Listen()
}
// Listen and serve.
// It serves client connection and broadcast request.