libnmdc: fix bugs with buffer splitting

This commit is contained in:
mappu 2016-04-03 19:20:58 +12:00
parent 73f6d66cbd
commit 8d7b0b46af
1 changed files with 3 additions and 3 deletions

View File

@ -74,7 +74,7 @@ var rx_incomingTo *regexp.Regexp
var ErrNotConnected error = errors.New("Not connected")
func init() {
rx_protocolMessage = regexp.MustCompile("(?ms)^[^|]*|")
rx_protocolMessage = regexp.MustCompile("(?ms)^[^|]*\\|")
rx_publicChat = regexp.MustCompile("(?ms)^<([^>]*)> (.*)$")
rx_incomingTo = regexp.MustCompile("(?ms)^([^ ]+) From: ([^ ]+) \\$<([^>]*)> (.*)")
}
@ -368,7 +368,7 @@ func (this *HubConnection) worker() {
// Read from socket into our local buffer (blocking)
if this.connValid {
readBuff := make([]byte, 4096)
readBuff := make([]byte, 1024)
nbytes, err = this.conn.Read(readBuff)
if nbytes > 0 {
fullBuffer += string(readBuff[0:nbytes])
@ -382,7 +382,7 @@ func (this *HubConnection) worker() {
}
protocolMessage := rx_protocolMessage.FindString(fullBuffer)
if len(protocolMessage) > 0 {
this.processProtocolMessage(protocolMessage)
this.processProtocolMessage(protocolMessage[:len(protocolMessage)-1])
fullBuffer = fullBuffer[len(protocolMessage):]
} else {
break