Java

Sending a Signal

Now that you have connected to the session and have a session object, you can now send a Signal. Signals are arbitrary text or data that are sent in a session which can be sent to a specific client or all connected clients. You can learn more about them in the Vonage Video Signaling developer guide. For this tutorial you will be sending text.

  1. Create a new class called SignalMessage with this code:

This class will be used to show the Signals in the UI.

  1. Copy the following code and paste it below the existing code in your MainActivity class after the onCreate function:

This code adds a function that will be called from the UI. session.signal is called to send the text as a Signal. session.signal takes the type of Signal and some data. The type is optional but can be used to differentiate between types of Signals in your app. If the Signal sends successfully, it is added to the array of messages that the UI is using.

  1. In the MainActivity class, update the end of the onCreate function to add a listener to the EditTextView which uses the sendMessage function:

When the EditTextView emits a done action, the sendMessage function will be called. Now time to update the UI:

  1. Open the activity_main.xml layout file (res > layout).
  2. Open the code view.
  3. Copy this XML over the existing layout:
  1. Create a new layout file called message_single_local.xml with this XML:
  1. Duplicate the message_single_local.xml, call it message_single_remote.xml, and change the gravity to start.
  2. Add an adapter for the message history ListView, create a class called SignalMessageAdapter with this code:

Adapters are used to populate views in a ListView, this defines a custom one for the Signals. Make sure to import any classes that are needed.

Basic text chat

Follow this tutorial to build basic text chat from scratch using the Vonage Video API. It is the quickest way to build a proof of concept for this functionality on the video platform.

以下の言語で利用可能:
JavaScript Java Swift
手順
1
Overview
2
Before You Begin
3
Configure a Vonage Video Application
4
Creating the Project
5
Setting Up Authentication
6
Connecting to the Session
7
Sending a Signal
8
Receiving a Signal
9
Testing your Code
10
Conclusion