001/* 002 * Copyright 2024 Vonage 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.vonage.client.conversations; 017 018import com.fasterxml.jackson.annotation.JsonCreator; 019import com.fasterxml.jackson.annotation.JsonValue; 020 021/** 022 * Represents the possible types of events in {@link Event#getType()}. 023 */ 024public enum EventType { 025 /** 026 * Event type is not defined in this enum. 027 */ 028 UNKNOWN, 029 030 /** 031 * Ephemeral (temporary) event. 032 */ 033 EPHEMERAL, 034 035 /** 036 * Custom event. 037 */ 038 CUSTOM, 039 040 /** 041 * Message event. See {@link com.vonage.client.common.MessageType} for the specifics. Applicable events are: 042 * Text, Image, Audio, Video, File, Template, Custom, VCard, Location, Random. 043 */ 044 MESSAGE, 045 046 /** 047 * Message submitted. 048 */ 049 MESSAGE_SUBMITTED, 050 051 /** 052 * Message rejected. 053 */ 054 MESSAGE_REJECTED, 055 056 /** 057 * Message could not be delivered. 058 */ 059 MESSAGE_UNDELIVERABLE, 060 061 /** 062 * Message has been seen. 063 */ 064 MESSAGE_SEEN, 065 066 /** 067 * Message has been delivered. 068 */ 069 MESSAGE_DELIVERED, 070 071 /** 072 * Play audio. 073 */ 074 AUDIO_PLAY, 075 076 /** 077 * Stop the audio currently playing. 078 */ 079 AUDIO_PLAY_STOP, 080 081 /** 082 * Use text-to-speech to say the given text. 083 */ 084 AUDIO_SAY, 085 086 /** 087 * Stop the currently playing text-to-speech. 088 */ 089 AUDIO_SAY_STOP, 090 091 /** 092 * Play DTMF audio. 093 */ 094 AUDIO_DTMF, 095 096 /** 097 * Record the audio. 098 */ 099 AUDIO_RECORD, 100 101 /** 102 * Stop current recording of audio. 103 */ 104 AUDIO_RECORD_STOP, 105 106 /** 107 * Mute audio, i.e. the producer won't be able to be heard by others. 108 */ 109 AUDIO_MUTE_ON, 110 111 /** 112 * Unmute audio, i.e. the producer will be able to be heard by others. 113 */ 114 AUDIO_MUTE_OFF, 115 116 /** 117 * Earmuff audio, i.e. the receiver won't be able to hear it. 118 */ 119 AUDIO_EARMUFF_ON, 120 121 /** 122 * Unearmuff audio, i.e. the receiver will be able to hear it. 123 */ 124 AUDIO_EARMUFF_OFF, 125 126 /** 127 * Event has been deleted. 128 */ 129 EVENT_DELETE, 130 131 /** 132 * Update on the status of a conversation leg. 133 */ 134 LEG_STATUS_UPDATE, 135 136 /** 137 * Conversation details have been updated. 138 */ 139 CONVERSATION_UPDATED, 140 141 /** 142 * Playing text-to-speech has finished. 143 */ 144 AUDIO_SAY_DONE, 145 146 /** 147 * Playing audio has finished. 148 */ 149 AUDIO_PLAY_DONE, 150 151 /** 152 * Audio recording has finished. 153 */ 154 AUDIO_RECORD_DONE, 155 156 /** 157 * Enable speaking. 158 */ 159 AUDIO_SPEAKING_ON, 160 161 /** 162 * Disable speaking. 163 */ 164 AUDIO_SPEAKING_OFF, 165 166 /** 167 * Automatic speech recognition has finished. 168 */ 169 AUDIO_ASR_DONE, 170 171 /** 172 * Automatic speech recognition of recording has finished. 173 */ 174 AUDIO_ASR_RECORD_DONE, 175 176 /** 177 * Status update on a member message. 178 */ 179 MEMBER_MESSAGE_STATUS, 180 181 /** 182 * Member has been invited to the conversation. 183 */ 184 MEMBER_INVITED, 185 186 /** 187 * Member has joined the conversation. 188 */ 189 MEMBER_JOINED, 190 191 /** 192 * Member has left the conversation. 193 */ 194 MEMBER_LEFT, 195 196 /** 197 * Member has media. 198 */ 199 MEMBER_MEDIA, 200 201 /** 202 * Status of SIP. 203 */ 204 SIP_STATUS, 205 206 /** 207 * SIP call has been hung up. 208 */ 209 SIP_HANGUP, 210 211 /** 212 * SIP call has been answered. 213 */ 214 SIP_ANSWERED, 215 216 /** 217 * SIP call encountered machine. 218 */ 219 SIP_MACHINE, 220 221 /** 222 * SIP call encountered machine using Advanced Machine Detection. 223 */ 224 SIP_AMD_MACHINE, 225 226 /** 227 * SIP call is ringing. 228 */ 229 SIP_RINGING, 230 231 /** 232 * RTC status. 233 */ 234 RTC_STATUS, 235 236 /** 237 * RTC call transfer. 238 */ 239 RTC_TRANSFER, 240 241 /** 242 * RTC call has hung up. 243 */ 244 RTC_HANGUP, 245 246 /** 247 * RTC call has been answered. 248 */ 249 RTC_ANSWERED, 250 251 /** 252 * RTC call is ringing. 253 */ 254 RTC_RINGING, 255 256 /** 257 * RTC call answer. 258 */ 259 RTC_ANSWER; 260 261 @JsonCreator 262 public static EventType fromString(String name) { 263 if (name == null || name.trim().isEmpty()) { 264 return null; 265 } 266 String upper = name.toUpperCase(); 267 if (upper.startsWith("CUSTOM:")) { 268 return CUSTOM; 269 } 270 try { 271 return valueOf(upper.replace(':', '_')); 272 } 273 catch (IllegalArgumentException ex) { 274 return EventType.UNKNOWN; 275 } 276 } 277 278 @JsonValue 279 @Override 280 public String toString() { 281 if (this == SIP_AMD_MACHINE) { 282 return "sip:amd_machine"; 283 } 284 return name().toLowerCase().replace('_', ':'); 285 } 286}