examples/chat: Various fixes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import "os"
|
||||
import "io"
|
||||
import "fmt"
|
||||
import "log"
|
||||
import "errors"
|
||||
@@ -48,7 +49,7 @@ func host(address string, certPath, keyPath string) error {
|
||||
|
||||
type client struct {
|
||||
conn hopp.Conn
|
||||
nickname hopp.Option[string]
|
||||
nickname string
|
||||
rooms usync.RWMonitor[map[string] hopp.Trans]
|
||||
}
|
||||
|
||||
@@ -58,13 +59,13 @@ func (this *client) run() {
|
||||
defer this.conn.Close()
|
||||
|
||||
for {
|
||||
log.Println("accepting transaction")
|
||||
trans, err := this.conn.AcceptTrans()
|
||||
if err != nil {
|
||||
log.Printf("XXX %v failed: %v", this.conn.RemoteAddr(), err)
|
||||
if !errors.Is(err, io.EOF) {
|
||||
log.Printf("XXX %v failed: %v", this.conn.RemoteAddr(), err)
|
||||
}
|
||||
return
|
||||
}
|
||||
log.Println("accepted transaction")
|
||||
go this.runTrans(trans)
|
||||
}
|
||||
}
|
||||
@@ -111,7 +112,7 @@ func (this *client) transTalk(trans hopp.Trans, initial *chat.MessageJoin) error
|
||||
}
|
||||
|
||||
func (this *client) handleMessageChat(trans hopp.Trans, room string, message *chat.MessageChat) error {
|
||||
log.Println("(). %s #%s: %s", this.nickname, room, message.Content)
|
||||
log.Printf("(). %s #%s: %s", this.nickname, room, message.Content)
|
||||
clients, done := clients.RBorrow()
|
||||
defer done()
|
||||
for client := range clients {
|
||||
|
||||
Reference in New Issue
Block a user