// broadcastMessage sends the given message to every writer
// if any writer is killed during the send, 'true' is returned
967237
func (mw *MirrorWriter) broadcastMessage(b []byte) bool {
	var dropped bool
	for i, w := range mw.writers {
		_, err := w.Write(b)
		if err != nil {
			mw.writers[i] = nil
			dropped = true
		}
	}
	return dropped
}
21699
func WriteMessageN(w io.Writer, msg Message, pver uint32, btcnet BitcoinNet) (int, error) {
	return WriteMessageWithEncodingN(w, msg, pver, btcnet, BaseEncoding)
}
47750
func (c *Conn) WriteMessage(messageType int, data []byte) error {

	if c.isServer && (c.newCompressionWriter == nil || !c.enableWriteCompression) {
		// Fast path with no allocations and single frame.

		var mw messageWriter
		if err := c.beginMessage(&mw, messageType); err != nil {
			return err
		}
		n := copy(c.writeBuf[mw.pos:], data)
		mw.pos += n
		data = data[n:]
		return mw.flushFrame(true, data)
	}

	w, err := c.NextWriter(messageType)
	if err != nil {
		return err
	}
	if _, err = w.Write(data); err != nil {
		return err
	}
	return w.Close()
}
235580
func (client *Client) PushMessage(to string, messages ...SendingMessage) *PushMessageCall {
	return &PushMessageCall{
		c:        client,
		to:       to,
		messages: messages,
	}
}
1199543
func (s *RenderingError) SetMessage(v string) *RenderingError {
	s.Message = &v
	return s
}
268128
func (w *WriteContext) WriteMessage(msg proto.Message) error {
	if DebugWire {
		fmt.Printf("<< %s %+v\n", reflect.TypeOf(msg).Elem().Name(), msg)
	}

	buf, err := proto.Marshal(msg)
	if err != nil {
		return errors.WithStack(err)
	}

	vibuflen := binary.PutUvarint(w.varintBuffer, uint64(len(buf)))
	if err != nil {
		return errors.WithStack(err)
	}
	_, err = w.writer.Write(w.varintBuffer[:vibuflen])
	if err != nil {
		return errors.WithStack(err)
	}

	_, err = w.writer.Write(buf)
	if err != nil {
		return errors.WithStack(err)
	}

	return nil
}
1359853
func logMessage(peer wtserver.Peer, msg wtwire.Message, read bool) {
	var action = "Received"
	var preposition = "from"
	if !read {
		action = "Sending"
		preposition = "to"
	}

	summary := wtwire.MessageSummary(msg)
	if len(summary) > 0 {
		summary = "(" + summary + ")"
	}

	log.Debugf("%s %s%v %s %x@%s", action, msg.MsgType(), summary,
		preposition, peer.RemotePub().SerializeCompressed(),
		peer.RemoteAddr())
}
1217335
func (s *ErrorInformation) SetMessage(v string) *ErrorInformation {
	s.Message = &v
	return s
}
1144116
func sendMessage(producer *client.AsyncProducer, msg utils.Message) error {
	var (
		msgKey   []byte
		msgMeta  []byte
		msgValue []byte
	)

	// init message
	if msg.Key != "" {
		msgKey = []byte(msg.Key)
	}
	if msg.Metadata != "" {
		msgMeta = []byte(msg.Metadata)
	}
	msgValue = []byte(msg.Text)

	// send message
	producer.SendMsgByte(msg.Topic, msgKey, msgValue, msgMeta)

	fmt.Println("message sent")
	return nil
}
1231315
func (s *Service) PublishMessage(msg *packet.Message) GenericFuture {
	s.mutex.Lock()
	defer s.mutex.Unlock()

	// allocate future
	f := future.New()

	// queue publish
	s.commandQueue <- &command{
		publish: true,
		future:  f,
		message: msg,
	}

	return f
}
591103
func (s *ImageStateChangeReason) SetMessage(v string) *ImageStateChangeReason {
	s.Message = &v
	return s
}
398366
func (buf *LogBuffer) PushMessage(msg string) {
	buf.msgLock.Lock()
	buf.messages.Value = msg
	buf.messages = buf.messages.Next()
	buf.msgLock.Unlock()
	if hook := buf.PushMessageHook; hook != nil {
		hook(msg)
	}
}
381825
func (s *Test) SetMessage(v string) *Test {
	s.Message = &v
	return s
}
840037
func (s *RootCauseException) SetMessage(v string) *RootCauseException {
	s.Message = &v
	return s
}
1071864
func (s *GetBatchPredictionOutput) SetMessage(v string) *GetBatchPredictionOutput {
	s.Message = &v
	return s
}
1226648
func (conR *ConsensusReactor) broadcastHasVoteMessage(vote *types.Vote) {
	msg := &HasVoteMessage{
		Height: vote.Height,
		Round:  vote.Round,
		Type:   vote.Type,
		Index:  vote.ValidatorIndex,
	}
	conR.Switch.Broadcast(StateChannel, cdc.MustMarshalBinaryBare(msg))
	/*
		// TODO: Make this broadcast more selective.
		for _, peer := range conR.Switch.Peers().List() {
			ps, ok := peer.Get(PeerStateKey).(*PeerState)
			if !ok {
				panic(fmt.Sprintf("Peer %v has no state", peer))
			}
			prs := ps.GetRoundState()
			if prs.Height == vote.Height {
				// TODO: Also filter on round?
				peer.TrySend(StateChannel, struct{ ConsensusMessage }{msg})
			} else {
				// Height doesn't match
				// TODO: check a field, maybe CatchupCommitRound?
				// TODO: But that requires changing the struct field comment.
			}
		}
	*/
}
132234
func (s *TableRestoreStatus) SetMessage(v string) *TableRestoreStatus {
	s.Message = &v
	return s
}