bugfix message history
This commit is contained in:
parent
0f7580954e
commit
a26cfccd19
|
@ -744,7 +744,6 @@ func main() {
|
|||
broadcastMsg = make(chan myMsg, 128)
|
||||
// Poor-Man's container/ring (circular buffer)
|
||||
myChatHist.msgs = make([]*myMsg, 128)
|
||||
msgIndex := 0
|
||||
|
||||
var addr string
|
||||
if 0 != int(*port) {
|
||||
|
@ -854,7 +853,7 @@ func main() {
|
|||
myHttpServer.chans <- bufConn
|
||||
case msg := <-broadcastMsg:
|
||||
// copy comes in, pointer gets saved (and not GC'd, I hope)
|
||||
myChatHist.msgs[msgIndex] = &msg
|
||||
myChatHist.msgs[myChatHist.i] = &msg
|
||||
myChatHist.i += 1
|
||||
if myChatHist.c < cap(myChatHist.msgs) {
|
||||
myChatHist.c += 1
|
||||
|
|
Loading…
Reference in New Issue