// Copyright 2019 The Gorilla WebSocket Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.packagewebsocketimport("io""strings")// JoinMessages concatenates received messages to create a single io.Reader.// The string term is appended to each message. The returned reader does not// support concurrent calls to the Read method.funcJoinMessages(c*Conn,termstring)io.Reader{return&joinReader{c:c,term:term}}typejoinReaderstruct{c*Conntermstringrio.Reader}func(r*joinReader)Read(p[]byte)(int,error){ifr.r==nil{varerrerror_,r.r,err=r.c.NextReader()iferr!=nil{return0,err}ifr.term!=""{r.r=io.MultiReader(r.r,strings.NewReader(r.term))}}n,err:=r.r.Read(p)iferr==io.EOF{err=nilr.r=nil}returnn,err}