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