// sendGenMsg sends a /b_gen command.
12777
func (buffer *Buffer) sendGenMsg(routine string, flags int, args ...float32) error {
	msg := osc.Message{
		Address: bufferGenAddress,
		Arguments: osc.Arguments{
			osc.Int(buffer.Num),
			osc.String(routine),
			osc.Int(int32(flags)),
		},
	}
	for _, arg := range args {
		msg.Arguments = append(msg.Arguments, osc.Float(arg))
	}
	if err := buffer.client.oscConn.Send(msg); err != nil {
		return err
	}
	return nil
}
954686
func (self *FSock) SendBgapiCmd(cmdStr string) (out chan string, err error) {
	jobUuid := genUUID()
	out = make(chan string)

	self.fsMutex.Lock()
	self.backgroundChans[jobUuid] = out
	self.fsMutex.Unlock()

	_, err = self.sendCmd(fmt.Sprintf("bgapi %s\nJob-UUID:%s\n", cmdStr, jobUuid))
	if err != nil {
		return nil, err
	}
	return
}
704741
func (this *Weixinmp) SendVoiceMsg(touser string, mediaId string) error {
	var msg voiceMsg
	msg.MsgType = "voice"
	msg.Voice.MediaId = mediaId
	return this.sendMsg(touser, &msg)
}
991492
func (z Keys) MarshalMsg(b []byte) (o []byte, err error) {
	o = msgp.Require(b, z.Msgsize())
	o = msgp.AppendArrayHeader(o, uint32(len(z)))
	for xvk := range z {
		if z[xvk] == nil {
			o = msgp.AppendNil(o)
		} else {
			o, err = z[xvk].MarshalMsg(o)
			if err != nil {
				return
			}
		}
	}
	return
}
965837
func ExpectMsg(r MsgReader, code uint64, content interface{}) error {
	msg, err := r.ReadMsg()
	if err != nil {
		return err
	}
	if msg.Code != code {
		return fmt.Errorf("message code mismatch: got %d, expected %d", msg.Code, code)
	}
	if content == nil {
		return msg.Discard()
	}
	contentEnc, err := rlp.EncodeToBytes(content)
	if err != nil {
		panic("content encode error: " + err.Error())
	}
	if int(msg.Size) != len(contentEnc) {
		return fmt.Errorf("message size mismatch: got %d, want %d", msg.Size, len(contentEnc))
	}
	actualContent, err := ioutil.ReadAll(msg.Payload)
	if err != nil {
		return err
	}
	if !bytes.Equal(actualContent, contentEnc) {
		return fmt.Errorf("message payload mismatch:\ngot:  %x\nwant: %x", actualContent, contentEnc)
	}
	return nil
}
224006
func (dht *IpfsDHT) sendMessage(ctx context.Context, p peer.ID, pmes *pb.Message) error {
	ctx, _ = tag.New(ctx, metrics.UpsertMessageType(pmes))

	ms, err := dht.messageSenderForPeer(ctx, p)
	if err != nil {
		stats.Record(ctx, metrics.SentMessageErrors.M(1))
		return err
	}

	if err := ms.SendMessage(ctx, pmes); err != nil {
		stats.Record(ctx, metrics.SentMessageErrors.M(1))
		return err
	}

	stats.Record(
		ctx,
		metrics.SentMessages.M(1),
		metrics.SentBytes.M(int64(pmes.Size())),
	)
	logger.Event(ctx, "dhtSentMessage", dht.self, p, pmes)
	return nil
}
810086
func (z *IterGen) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 3
	// write "T0"
	err = en.Append(0x83, 0xa2, 0x54, 0x30)
	if err != nil {
		return
	}
	err = en.WriteUint32(z.T0)
	if err != nil {
		err = msgp.WrapError(err, "T0")
		return
	}
	// write "IntervalHint"
	err = en.Append(0xac, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x48, 0x69, 0x6e, 0x74)
	if err != nil {
		return
	}
	err = en.WriteUint32(z.IntervalHint)
	if err != nil {
		err = msgp.WrapError(err, "IntervalHint")
		return
	}
	// write "B"
	err = en.Append(0xa1, 0x42)
	if err != nil {
		return
	}
	err = en.WriteBytes(z.B)
	if err != nil {
		err = msgp.WrapError(err, "B")
		return
	}
	return
}
492963
func NewMsg(u *dt.User, cmd string) (*dt.Msg, error) {
	tokens := TokenizeSentence(cmd)
	stems := StemTokens(tokens)
	si := ner.classifyTokens(tokens)

	// Get the intents as determined by each plugin
	for pluginID, c := range bClassifiers {
		scores, idx, _ := c.ProbScores(stems)
		log.Debug("intent score", pluginIntents[pluginID][idx],
			scores[idx])
		if scores[idx] > 0.7 {
			si.Intents = append(si.Intents,
				string(pluginIntents[pluginID][idx]))
		}
	}

	m := &dt.Msg{
		User:            u,
		Sentence:        cmd,
		Tokens:          tokens,
		Stems:           stems,
		StructuredInput: si,
	}
	if err := saveContext(db, m); err != nil {
		return nil, err
	}
	if err := addContext(db, m); err != nil {
		return nil, err
	}
	return m, nil
}
273038
func SendGroupMessage(hexid string, msg string) (uint64, error) {
	return sendGroupHelper(hexid, msg, nil)
}
95759
func (z *bitmapContainer) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 2
	// write "cardinality"
	err = en.Append(0x82, 0xab, 0x63, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.cardinality)
	if err != nil {
		return
	}
	// write "bitmap"
	err = en.Append(0xa6, 0x62, 0x69, 0x74, 0x6d, 0x61, 0x70)
	if err != nil {
		return err
	}
	err = en.WriteArrayHeader(uint32(len(z.bitmap)))
	if err != nil {
		return
	}
	for zxvk := range z.bitmap {
		err = en.WriteUint64(z.bitmap[zxvk])
		if err != nil {
			return
		}
	}
	return
}
893358
func (z *containerSerz) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 2
	// write "t"
	err = en.Append(0x82, 0xa1, 0x74)
	if err != nil {
		return err
	}
	err = en.WriteUint8(uint8(z.t))
	if err != nil {
		return
	}
	// write "r"
	err = en.Append(0xa1, 0x72)
	if err != nil {
		return err
	}
	err = z.r.EncodeMsg(en)
	if err != nil {
		return
	}
	return
}
259610
func (this *Weixinmp) SendImageMsg(touser string, mediaId string) error {
	var msg imageMsg
	msg.MsgType = "image"
	msg.Image.MediaId = mediaId
	return this.sendMsg(touser, &msg)
}
633423
func (s *Server) sendInternalMsg(sub, rply string, si *ServerInfo, msg interface{}) {
	if s.sys == nil || s.sys.sendq == nil {
		return
	}
	sendq := s.sys.sendq
	// Don't hold lock while placing on the channel.
	s.mu.Unlock()
	sendq <- &pubMsg{sub, rply, si, msg, false}
	s.mu.Lock()
}
922347
func (c *SocketConnection) SendMsg(msg map[string]string, uuid, data string) (m *Message, err error) {

	b := bytes.NewBufferString("sendmsg")

	if uuid != "" {
		if strings.Contains(uuid, "\r\n") {
			return nil, fmt.Errorf(EInvalidCommandProvided, msg)
		}

		b.WriteString(" " + uuid)
	}

	b.WriteString("\n")

	for k, v := range msg {
		if strings.Contains(k, "\r\n") {
			return nil, fmt.Errorf(EInvalidCommandProvided, msg)
		}

		if v != "" {
			if strings.Contains(v, "\r\n") {
				return nil, fmt.Errorf(EInvalidCommandProvided, msg)
			}

			b.WriteString(fmt.Sprintf("%s: %s\n", k, v))
		}
	}

	b.WriteString("\n")

	if msg["content-length"] != "" && data != "" {
		b.WriteString(data)
	}

	// lock mutex
	c.mtx.Lock()
	_, err = b.WriteTo(c)
	if err != nil {
		c.mtx.Unlock()
		return nil, err
	}
	c.mtx.Unlock()

	select {
	case err := <-c.err:
		return nil, err
	case m := <-c.m:
		return m, nil
	}
}
1262603
func (r *RoundRobinResponseWriter) WriteMsg(res *dns.Msg) error {
	if res.Rcode != dns.RcodeSuccess {
		return r.ResponseWriter.WriteMsg(res)
	}

	res.Answer = roundRobin(res.Answer)
	res.Ns = roundRobin(res.Ns)
	res.Extra = roundRobin(res.Extra)

	return r.ResponseWriter.WriteMsg(res)
}
867384
func SendMessageMarshalled(command, family, flags int, v interface{}) error {
	msg, err := NewMessage(command, family, flags)
	if err != nil {
		return err
	}
	defer msg.Free()

	if err := msg.Marshal(v); err != nil {
		return err
	}
	return msg.Send()
}
53857
func (z IndexTagDelSeriesResp) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 1
	// write "Count"
	err = en.Append(0x81, 0xa5, 0x43, 0x6f, 0x75, 0x6e, 0x74)
	if err != nil {
		return
	}
	err = en.WriteInt(z.Count)
	if err != nil {
		err = msgp.WrapError(err, "Count")
		return
	}
	return
}