// tries to send a message, returns true if successful
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
}
912394
func (t *HTTPTransporter) Send(ctx context.Context, msg *Message) (sendError error) {
	return t.getState().Send(ctx, msg)
}
1132364
func (c *Client) Send(msg *Message) error {
	buf, err := json.Marshal(msg)
	if err != nil {
		return err
	}
	resp, err := c.HTTPClient.Post(c.url, "application/json", bytes.NewReader(buf))
	if err != nil {
		return err
	}
	defer resp.Body.Close()

	// Discard response body to reuse connection
	io.Copy(ioutil.Discard, resp.Body)

	if resp.StatusCode != 200 {
		return fmt.Errorf("unexpected status code: %d", resp.StatusCode)
	}
	return nil
}
1107538
func send(ch chan Payload, r *payload, needReply bool) {
	if needReply {
		r.done = make(chan struct{})
		defer func() { <-r.done }()
	}

	ch <- r
}
1360849
func (c *Conversation) Send(m ValidMessage, trace ...interface{}) ([]ValidMessage, error) {
	message := makeCopy(m)
	defer wipeBytes(message)

	if !c.Policies.isOTREnabled() {
		return []ValidMessage{makeCopy(message)}, nil
	}

	if c.debug && bytes.Index(message, []byte(debugString)) != -1 {
		c.dump(bufio.NewWriter(standardErrorOutput))
		return nil, nil
	}

	switch c.msgState {
	case plainText:
		return c.withInjections(c.sendMessageOnPlaintext(message, trace...))
	case encrypted:
		return c.withInjections(c.sendMessageOnEncrypted(message))
	case finished:
		c.messageEvent(MessageEventConnectionEnded)
		return c.withInjections(nil, newOtrError("cannot send message because secure conversation has finished"))
	}

	return c.withInjections(nil, newOtrError("cannot send message in current state"))
}
1004312
func (m *Message) Send(c slack.Client) (*MessageResponse, error) {
	resp := &MessageResponse{}
	if err := c.Send(PostMessageEndpoint, m, resp); err != nil {
		return nil, err
	}

	return resp, nil
}
795015
func (worker *Worker) Send(command, option string, msg []string) (err error) {
	n := 4
	if option != "" {
		n++
	}
	m := make([]string, n, n+len(msg))
	m = append(m, msg...)

	//  Stack protocol envelope to start of message
	if option != "" {
		m[4] = option
	}
	m[3] = command
	m[2] = mdapi.MDPW_WORKER

	//  Stack routing envelope to start of message
	m[1] = ""
	m[0] = worker.identity

	if worker.broker.verbose {
		log.Printf("I: sending %s to worker %q\n", mdapi.MDPS_COMMANDS[command], m)
	}
	_, err = worker.broker.socket.SendMessage(m)
	return
}
673446
func (rtm *Client) SendMessage(m *Message) error {
	rtm.socketLock.RLock()
	defer rtm.socketLock.RUnlock()

	if rtm.socketConnection == nil {
		return exception.New("Connection is closed.")
	}

	return rtm.socketConnection.WriteJSON(m)
}
198848
func (p *conn) Send(msg *Message) error {

	l := uint64(len(msg.Header) + len(msg.Body))

	if msg.Expired() {
		msg.Free()
		return nil
	}

	// send length header
	if err := binary.Write(p.c, binary.BigEndian, l); err != nil {
		return err
	}
	if _, err := p.c.Write(msg.Header); err != nil {
		return err
	}
	// hope this works
	if _, err := p.c.Write(msg.Body); err != nil {
		return err
	}
	msg.Free()
	return nil
}
216152
func (resp *Response) Fail(msg ...interface{}) *Response {
	resp.assertion.True(resp.resp.StatusCode >= 400, msg...)

	return resp
}
797372
func (m *MMClient) SendDirectMessage(toUserId string, msg string, rootId string) { //nolint:golint
	m.SendDirectMessageProps(toUserId, msg, rootId, nil)
}
765745
func (c *Client) Send(message string) error {
	_, err := c.conn.Write([]byte(message))
	return err
}
845302
func (c *Called) FailureMessage(actual interface{}) (message string) {
	message = fmt.Sprintf("Expected %#v to be called", actual)
	if len(c.matchFailures) == 0 {
		return message
	}
	return message + " with args:\n" + strings.Join(c.matchFailures, "\n")
}
662696
func (c *Client) Send(msg Message) error {
	select {
	case c.send <- msg:
		return nil
	default:
		// No send channel means we have disconnected, time to
		// cleanup.
		return nil
	}
}
1030632
func (c *Channel) SendMessage(message *Message) {
	c.lastEventID = message.id

	for c, open := range c.clients {
		if open {
			c.send <- message
		}
	}
}
1273886
func SendMessage(serverID, to, method, message string) error {
	buffer := []byte(message)
	return SendtBytes(serverID, to, method, buffer)
}
819113
func (s *Status) Message() string {
	if s == nil || s.s == nil {
		return ""
	}
	return s.s.Message
}