// sendUserMsg is used to stream a user message to another host.
177307
func (m *Memberlist) sendUserMsg(addr string, sendBuf []byte) error {
	conn, err := m.transport.DialTimeout(addr, m.config.TCPTimeout)
	if err != nil {
		return err
	}
	defer conn.Close()

	bufConn := bytes.NewBuffer(nil)
	if err := bufConn.WriteByte(byte(userMsg)); err != nil {
		return err
	}

	header := userMsgHeader{UserMsgLen: len(sendBuf)}
	hd := codec.MsgpackHandle{}
	enc := codec.NewEncoder(bufConn, &hd)
	if err := enc.Encode(&header); err != nil {
		return err
	}
	if _, err := bufConn.Write(sendBuf); err != nil {
		return err
	}
	return m.rawSendMsgStream(conn, bufConn.Bytes())
}
509472
func (s *ScrubWriter) WriteMsg(m *dns.Msg) error {
	state := Request{Req: s.req, W: s.ResponseWriter}

	n := state.Scrub(m)
	state.SizeAndDo(n)
	return s.ResponseWriter.WriteMsg(n)
}
1195179
func (this *Weixinmp) SendNewsMsg(touser string, articles *[]Article) error {
	var msg newsMsg
	msg.MsgType = "news"
	msg.Articles.Item = articles
	return this.sendMsg(touser, &msg)
}
479653
func (c *Client) SendMessage(channel, message, username string) error {
	if channel == "" || message == "" || username == "" {
		return errors.New("channel, message, and username required")
	}

	payload := url.Values{}
	payload.Set("token", c.token)
	payload.Set("channel", channel)
	payload.Set("text", message)
	payload.Set("username", username)

	res, err := http.PostForm(fmt.Sprintf("%s/%s", slackAddr, postMessageURI), payload)
	if err != nil {
		return err
	}
	defer res.Body.Close()

	resBody := new(slackPostMessageRes)
	decoder := json.NewDecoder(res.Body)
	err = decoder.Decode(resBody)
	if err != nil {
		return err
	}

	if !resBody.Ok {
		return errors.New(resBody.Error)
	}

	return nil
}
1197841
func (this *Weixinmp) SendMusicMsg(touser string, music *Music) error {
	var msg musicMsg
	msg.MsgType = "music"
	msg.Music = music
	return this.sendMsg(touser, &msg)
}
1188686
func (nc *Conn) PublishMsg(m *Msg) error {
	if m == nil {
		return ErrInvalidMsg
	}
	return nc.publish(m.Subject, m.Reply, m.Data)
}
965277
func sendMsg(p *Pss, sp *network.Peer, msg *PssMsg) bool {
	var isPssEnabled bool
	info := sp.Info()
	for _, capability := range info.Caps {
		if capability == p.capstring {
			isPssEnabled = true
			break
		}
	}
	if !isPssEnabled {
		log.Error("peer doesn't have matching pss capabilities, skipping", "peer", info.Name, "caps", info.Caps)
		return false
	}

	// get the protocol peer from the forwarding peer cache
	p.fwdPoolMu.RLock()
	pp := p.fwdPool[sp.Info().ID]
	p.fwdPoolMu.RUnlock()

	err := pp.Send(context.TODO(), msg)
	if err != nil {
		metrics.GetOrRegisterCounter("pss.pp.send.error", nil).Inc(1)
		log.Error(err.Error())
	}

	return err == nil
}
208283
func (self *FSock) SendMsgCmd(uuid string, cmdargs map[string]string) error {
	return self.SendMsgCmdWithBody(uuid, cmdargs, "")
}
366322
func (gitter *Gitter) SendMessage(roomID, text string) (*Message, error) {

	message := Message{Text: text}
	body, _ := json.Marshal(message)
	response, err := gitter.post(gitter.config.apiBaseURL+"rooms/"+roomID+"/chatMessages", body)
	if err != nil {
		gitter.log(err)
		return nil, err
	}

	err = json.Unmarshal(response, &message)
	if err != nil {
		gitter.log(err)
		return nil, err
	}

	return &message, nil
}
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
}
2685
func (l *Logger) TraceMsg(message string, keyvals ...interface{}) error {
	return Msg(l.Trace, message, keyvals...)
}
545176
func (c *Client) sendMessage(marshalledJSON []byte) {
	// Don't send the message if disconnected.
	select {
	case c.sendChan <- marshalledJSON:
	case <-c.disconnectChan():
		return
	}
}
971112
func (c *InternalClient) SendMessage(ctx context.Context, uri *pilosa.URI, msg []byte) error {
	span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.SendMessage")
	defer span.Finish()

	u := uriPathToURL(uri, "/internal/cluster/message")
	req, err := http.NewRequest("POST", u.String(), bytes.NewReader(msg))
	if err != nil {
		return errors.Wrap(err, "making new request")
	}
	req.Header.Set("Content-Type", "application/x-protobuf")
	req.Header.Set("User-Agent", "pilosa/"+pilosa.Version)
	req.Header.Set("Accept", "application/json")

	// Execute request.
	resp, err := c.executeRequest(req.WithContext(ctx))
	if err != nil {
		return errors.Wrap(err, "executing request")
	}
	return errors.Wrap(resp.Body.Close(), "closing response body")
}
531788
func UserMessage(e error) string {
	if e == nil {
		return ""
	}
	msg, _ := Value(e, userMessage).(string)
	return msg
}
1195596
func (z *Event) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 5
	// write "id"
	err = en.Append(0x85, 0xa2, 0x69, 0x64)
	if err != nil {
		return
	}
	err = en.WriteInt(z.Id)
	if err != nil {
		return
	}
	// write "user"
	// map header, size 2
	// write "first"
	err = en.Append(0xa4, 0x75, 0x73, 0x65, 0x72, 0x82, 0xa5, 0x66, 0x69, 0x72, 0x73, 0x74)
	if err != nil {
		return
	}
	err = en.WriteString(z.User.First)
	if err != nil {
		return
	}
	// write "last"
	err = en.Append(0xa4, 0x6c, 0x61, 0x73, 0x74)
	if err != nil {
		return
	}
	err = en.WriteString(z.User.Last)
	if err != nil {
		return
	}
	// write "flight"
	err = en.Append(0xa6, 0x66, 0x6c, 0x69, 0x67, 0x68, 0x74)
	if err != nil {
		return
	}
	err = en.WriteString(z.Flight)
	if err != nil {
		return
	}
	// write "pilot"
	err = en.Append(0xa5, 0x70, 0x69, 0x6c, 0x6f, 0x74)
	if err != nil {
		return
	}
	err = en.WriteArrayHeader(uint32(len(z.Pilot)))
	if err != nil {
		return
	}
	for za0001 := range z.Pilot {
		err = en.WriteString(z.Pilot[za0001])
		if err != nil {
			return
		}
	}
	// write "cancelled"
	err = en.Append(0xa9, 0x63, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x6c, 0x65, 0x64)
	if err != nil {
		return
	}
	err = en.WriteBool(z.Cancelled)
	if err != nil {
		return
	}
	return
}
1000110
func (s *SQS) SendMessage(in *sqs.SendMessageInput) (*sqs.SendMessageOutput, error) {
	s.lastSent = aws.StringValue(in.MessageBody)

	hasher := md5.New()
	hasher.Write([]byte(aws.StringValue(in.MessageBody)))
	hash := fmt.Sprintf("%x", hasher.Sum(nil))

	return &sqs.SendMessageOutput{
		MD5OfMessageBody: aws.String(hash),
	}, nil
}
1318168
func sendMessages(c net.PacketConn, source net.HardwareAddr, msg string) {
	// Message is broadcast to all machines in same network segment.
	f := &ethernet.Frame{
		Destination: ethernet.Broadcast,
		Source:      source,
		EtherType:   etherType,
		Payload:     []byte(msg),
	}

	b, err := f.MarshalBinary()
	if err != nil {
		log.Fatalf("failed to marshal ethernet frame: %v", err)
	}

	// Required by Linux, even though the Ethernet frame has a destination.
	// Unused by BSD.
	addr := &raw.Addr{
		HardwareAddr: ethernet.Broadcast,
	}

	// Send message forever.
	t := time.NewTicker(1 * time.Second)
	for range t.C {
		if _, err := c.WriteTo(b, addr); err != nil {
			log.Fatalf("failed to send message: %v", err)
		}
	}
}