メニュー

Expand
ページを評価:

タイピングインジケーター

The Conversations Typing Indicator feature enables typing signals to be sent for Participants from their client endpoints when they are typing within a Conversatiion.

These signals are then sent to all other connected Participants of the Conversation, allowing for UI features to be implemented, such as showing "User is typing" style messages or indicators for Conversation Participants. Typing is always within the context of a Conversation and a Participant.

The Typing Indicator feature follows a producer/consumer model, with the Conversations SDKs exposing API methods to set when the User is typing in a Conversation. This is signaled via Conversations in real time to other Participants of the Conversation, where events are fired for the typing event.

目次

タイピングインジケーターの送信

The Conversations Typing Indicator is always in relation to a Conversation - allowing Typing to be correctly indicated within the Conversation where the Participant is typing.

Note: The Typing Indicator signal is not automatically sent by Conversations. The Typing Indicator must be explicitly sent using the relevant SDK API methods.

Note: To optimise network traffic, Conversations client endpoints will only send a Typing signal once every 5 seconds by default, even if the Typing API command is called more frequently. The send threshold value can be configured for a Service instance by setting the TypingIndicatorTimeout property of the Services resource. Note that reducing this value will cause more network traffic to be generated by client endpoints calling the Typing API.

To send the Typing Indicator from a web-based front end, the following Javascript code can be used:

// intercept the keydown event
inputBox.on('keydown', function(e) {
  // if the RETURN/ENTER key is pressed, send the message
  if (e.keyCode === 13) {
    sendButton.click();
  } else {
    // else send the Typing Indicator signal
    activeConversation.typing();
  }
});

タイピングインジケーターの消費

In order to display the Typing Indicator when other Participants are typing within a Conversation, the Typing Indicator Events must be consumed and processed on the clients. This is done by listening for the relevant Typing Indicator events/callbacks and processing these appropriately.

Note: The Typing Indicator signal is not automatically sent by Conversations. Typing events will not be received if the Participant does not send them explicitly (see the previous section).

Here is an example of listening for the Typing event and then processing this to display a "typing" message for the relevant Participant. You would implement your own updateTypingIndicator method:

//set up the listener for the typing started Conversation event
activeConversation.on('typingStarted', function(participant) {
    //process the participant to show typing
    updateTypingIndicator(participant, true);
});

//set  the listener for the typing ended Conversation event
activeConversation.on('typingEnded', function(participant) {
    //process the participant to stop showing typing
    updateTypingIndicator(participant, false);
});
ページを評価:

ヘルプが必要ですか?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Community Forums or browsing the Twilio tag on Stack Overflow.

        
        
        

        フィードバックくださりありがとうございます!

        We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        ステップ1

        Get link

        Get a free personal referral link here

        ステップ2:

        Give $10

        Your user signs up and upgrade using link

        ステップ3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more