connection.go
func (ch *Channel) recvMsgPacket(packet msgPacket) ([]byte, error) {
	// log.Debug("Read Msg Packet", "conn", ch.conn, "packet", packet)
	if ch.desc.RecvMessageCapacity < len(ch.recving)+len(packet.Bytes) {
		return nil, wire.ErrBinaryReadOverflow
	}
	ch.recving = append(ch.recving, packet.Bytes...)
	if packet.EOF == byte(0x01) {
		msgBytes := ch.recving
		// clear the slice without re-allocating.
		// http://stackoverflow.com/questions/16971741/how-do-you-clear-a-slice-in-go
		//   suggests this could be a memory leak, but we might as well keep the memory for the channel until it closes,
		//	at which point the recving slice stops being used and should be garbage collected
		ch.recving = ch.recving[:0] // make([]byte, 0, ch.desc.RecvBufferCapacity)
		return msgBytes, nil
	}
	return nil, nil
}
func (ch *Channel) recvMsgPacket(packet msgPacket) ([]byte, error) {
	// log.Debug("Read Msg Packet", "conn", ch.conn, "packet", packet)
	if ch.desc.RecvMessageCapacity < len(ch.recving)+len(packet.Bytes) {
		return nil, wire.ErrBinaryReadOverflow
	}
	ch.recving = append(ch.recving, packet.Bytes...)
	if packet.EOF == byte(0x01) {
		msgBytes := ch.recving
		// clear the slice without re-allocating.
		// http://stackoverflow.com/questions/16971741/how-do-you-clear-a-slice-in-go
		//   suggests this could be a memory leak, but we might as well keep the memory for the channel until it closes,
		//	at which point the recving slice stops being used and should be garbage collected
		ch.recving = ch.recving[:0] // make([]byte, 0, ch.desc.RecvBufferCapacity)
		return msgBytes, nil
	}
	return nil, nil
}
func ( ch * Channel ) recvMsgPacket ( packet msgPacket ) ( [ ] byte , error ) { // log.Debug("Read Msg Packet", "conn", ch.conn, "packet", packet) if ch . desc . RecvMessageCapacity < len ( ch . recving ) + len ( packet . Bytes ) { return nil , wire . ErrBinaryReadOverflow } ch . recving = append ( ch . recving , packet . Bytes ... ) if packet . EOF == byte ( 0x01 ) { msgBytes := ch . recving // clear the slice without re-allocating. // http://stackoverflow.com/questions/16971741/how-do-you-clear-a-slice-in-go //   suggests this could be a memory leak, but we might as well keep the memory for the channel until it closes, //	at which point the recving slice stops being used and should be garbage collected ch . recving = ch . recving [ : 0 ] // make([]byte, 0, ch.desc.RecvBufferCapacity) return msgBytes , nil } return nil , nil }
// Handles incoming msgPackets. Returns a msg bytes if msg is complete.
// Not goroutine-safe
Handles incoming msgPackets . Returns a msg bytes if msg is complete . Not goroutine - safe