Send Audio message

@param peer       destination peer
@param duration   audio duration
@param descriptor File Descriptor
501291
@ObjectiveCName("sendAudioWithPeer:withName:withDuration:withDescriptor:")
    public void sendAudio(@NotNull Peer peer, @NotNull String fileName,
                          int duration, @NotNull String descriptor) {
        modules.getMessagesModule().sendAudio(peer, fileName, duration, descriptor);
    }
1201766
def send_audio_file(
        self, audio_file, device_state, authentication_headers,
        dialog_request_id, distance_profile, audio_format
    ):
        

        payload = {
            'context': device_state,
            'event': {
                'header': {
                    'namespace': 'SpeechRecognizer',
                    'name': 'Recognize',
                    'messageId': self.generate_message_id(),
                    'dialogRequestId': dialog_request_id,
                },
                'payload': {
                    'profile': distance_profile,
                    'format': audio_format
                }
            }
        }
        multipart_data = MultipartEncoder(
            fields=[
                (
                    'request', (
                        'request',
                        json.dumps(payload),
                        'application/json;',
                        {'Content-Disposition': "form-data; name='request'"}
                    ),
                ),
                (
                    'audio', (
                        'audio',
                        audio_file,
                        'application/octet-stream',
                        {'Content-Disposition': "form-data; name='audio'"}
                    )
                ),
            ],
            boundary='boundary',
        )
        headers = {
            **authentication_headers,
            'Content-Type': multipart_data.content_type
        }
        stream_id = self.connection.request(
            'POST',
            '/v20160207/events',
            headers=headers,
            body=multipart_data,
        )
        response = self.connection.get_response(stream_id)
        return self.parse_response(response)
196167
public void send(PeerMessage message) throws IllegalStateException {
    logger.trace("Sending msg {} to {}", message.getType(), this);
    if (this.isConnected()) {
      ByteBuffer data = message.getData();
      data.rewind();
      connectionManager.offerWrite(new WriteTask(socketChannel, data, new WriteListener() {
        @Override
        public void onWriteFailed(String message, Throwable e) {
          if (e == null) {
            logger.info(message);
          } else if (e instanceof ConnectionClosedException){
            logger.debug(message, e);
            unbind(true);
          } else {
            LoggerUtils.warnAndDebugDetails(logger, message, e);
          }

        }

        @Override
        public void onWriteDone() {
        }
      }), 1, TimeUnit.SECONDS);
    } else {
      logger.trace("Attempting to send a message to non-connected peer {}!", this);
      unbind(true);
    }
  }
483722
function onPeerConnected(peer)
    {
        if(scope.localStream)
        {
            peer.updateStream(scope.localStream,false);
        }
        scope._servConn.sendRTCState(true,peer.id);

        scope.dispatchEvent("peerConnected",peer.id);
    }
1299398
private static void addDataEventListenerToPeer(Executor executor, Peer peer, PeerDataEventListener downloadListener) {
        peer.addBlocksDownloadedEventListener(executor, downloadListener);
        peer.addChainDownloadStartedEventListener(executor, downloadListener);
        peer.addGetDataEventListener(executor, downloadListener);
        peer.addPreMessageReceivedEventListener(executor, downloadListener);
    }
1305181
@ObjectiveCName("sendCustomJsonMessageWithPeer:withJson:")
    public void sendCustomJsonMessage(@NotNull Peer peer, @NotNull JsonContent content) {
        modules.getMessagesModule().sendJson(peer, content);
    }
473327
@ObjectiveCName("deleteMessagesWithPeer:withRids:")
    public void deleteMessages(Peer peer, long[] rids) {
        modules.getMessagesModule().deleteMessages(peer, rids);
    }
869538
@ObjectiveCName("onConversationOpenWithPeer:")
    public void onConversationOpen(@NotNull Peer peer) {
        modules.getEvents().post(new PeerChatOpened(peer));
    }
1012196
@Override
	protected final void sendToDestination(Destination destination, boolean destinationOverride, Message srcMessage, int deliveryMode, int priority, long timeToLive) throws JMSException
    {
        // Check that the destination was specified
        if (destination == null)
            throw new InvalidDestinationException("Destination not specified");  // [JMS SPEC]

        // Create an internal copy if necessary
        AbstractMessage message = MessageTools.makeInternalCopy(srcMessage);
        
        externalAccessLock.readLock().lock();
        try
		{
    		checkNotClosed();
    		
	        // Dispatch to session
            ((LocalSession)session).dispatch(message);
		}
        finally
        {
        	externalAccessLock.readLock().unlock();
        }
    }
338803
def send_audio(self, audio: str, reply: Message=None, on_success: callable=None,
                   reply_markup: botapi.ReplyMarkup=None):
        

        self.twx.send_audio(peer=self, audio=audio, reply_to_message_id=reply, on_success=on_success,
                            reply_markup=reply_markup)
172736
public void addDisconnectedEventListener(Executor executor, PeerDisconnectedEventListener listener) {
        peerDisconnectedEventListeners.add(new ListenerRegistration<>(checkNotNull(listener), executor));
        for (Peer peer : getConnectedPeers())
            peer.addDisconnectedEventListener(executor, listener);
        for (Peer peer : getPendingPeers())
            peer.addDisconnectedEventListener(executor, listener);
    }
1337484
@Override
    	protected void doSuccessResponse(SipServletResponse resp)
			throws ServletException, IOException {
		if (resp.getStatus() == SipServletResponse.SC_OK) {
			String audioFilePath = (String)getServletContext().getAttribute("audioFilePath");
			logger.info("audio file path is " + audioFilePath);
			try {
				MsPeer peer = MsPeerFactory.getPeer("org.mobicents.mscontrol.impl.MsPeerImpl");
				MsProvider provider = peer.getProvider();
				MsSession session = provider.createSession();
				MsConnection connection = session.createNetworkConnection(PR_JNDI_NAME);
				MediaConnectionListener listener = new MediaConnectionListener();
				listener.setResponse(resp);
				listener.setAudioFilePath(audioFilePath);
				connection.addConnectionListener(listener);
				Object sdpObj = resp.getContent();
				byte[] sdpBytes = (byte[]) sdpObj;
				String sdp = new String(sdpBytes); 
				connection.modify("$", sdp);
			} catch (ClassNotFoundException e) {
				logger.error("class not found ", e);
			}			
		}
	}
193308
def _listen(self, protocols, From, description):
        
        # The peer is coming from a client-side representation of the user
        # described by 'From', and talking *to* a server-side representation of
        # the user described by 'From'.
        self.verifyCertificateAllowed(From, From)
        theirCert = Certificate.peerFromTransport(self.transport)
        for protocolName in protocols:
            if protocolName.startswith('.'):
                raise VerifyError(
                    "Internal protocols are for server-server use _only_: %r" %
                    protocolName)

            key = (From, protocolName)
            value = (self, theirCert, description)
            log.msg("%r listening for %r" % key)
            self.listeningClient.append((key, value))
            self.service.listeningClients.setdefault(key, []).append(value)
        return {}
985637
@ObjectiveCName("sendPhotoWithPeer:withName:withW:withH:withThumb:withDescriptor:")
    public void sendPhoto(@NotNull Peer peer, @NotNull String fileName,
                          int w, int h, @Nullable FastThumb fastThumb,
                          @NotNull String descriptor) {
        modules.getMessagesModule().sendPhoto(peer, fileName, w, h, fastThumb, descriptor);
    }
1255339
public void send(Object message, long delay, ActorRef sender) {
        dispatcher.sendMessage(endpoint, message, ActorTime.currentTime() + delay, sender);
    }
1157250
private void sendCommandToAll(ReplicableCommand command, long requestId, DeliverOrder deliverOrder, boolean rsvp) {
      Message message = new Message();
      marshallRequest(message, command, requestId);
      setMessageFlags(message, deliverOrder, rsvp, true);

      if (deliverOrder == DeliverOrder.TOTAL) {
         message.dest(new AnycastAddress());
      }

      send(message);
   }
867557
protected void broadcastTo (
        DObject object, Name from, byte levelOrMode, String bundle, String msg)
    {
        if (from == null) {
            SpeakUtil.sendSystem(object, bundle, msg, levelOrMode /* level */);

        } else {
            SpeakUtil.sendSpeak(object, from, bundle, msg, levelOrMode /* mode */);
        }
    }