Repository navigation
Expand file tree
/
Copy pathSSIPClient.java
More file actions
694 lines (626 loc) · 23.5 KB
/
Copy pathSSIPClient.java
File metadata and controls
694 lines (626 loc) · 23.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
/*
* SSIPClient.java
*
* Copyright (C) 2008, 2010 Rui Batista <rui.batista@ist.utl.pt>
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this package; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
package speechd.ssip;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Logger;
/**
* Basic high level, java interface to SSIP servers like speech-dispatcher.
* This is the recomended way to communicate with SSIP servers in java, almost all SSIP commands are supported directly. A {@code SSIPClient} instance represents a connection to one SSIP server, it can be used for speaking, changing speech parameters, etc... without knowning about SSIP protocole details, altough familiarity with SSIP concepts is useful.
* When this class doesn't provide the needed functionality, clients can subclass it and/or use {@link SSIPConnection} objects to send and receive raw SSIP data.<br/>
* SSIP events are also supported, see the {@link SSIPEventHandler} interface, {@link SSIPClient#setNotification(boolean)}, {@link SSIPClient#setNotification(boolean, speechd.ssip.SSIPEvent.EventType)} and {@link SSIPClient#setEventHandler(SSIPEventHandler)} methods.
* A {@code SSIPClient} instance should be used just for one connection, when closed it must be discarded.
* We recomend closing connections after using them, it will free network resources earlier.
* This class is safe for multi threaded use.
* All activities are logged to the {@code speechd.ssip.SSIPClient} logger (java logging api).
*
* <h4>notes</h4>
* <p>This interface is based on the <a href="http://www.freebsoft.org/doc/speechd/speech-dispatcher_15.html#SEC60">python</a> and <a href="http://www.freebsoft.org/doc/speechd/speech-dispatcher_14.html#SEC44">c</a> speech-dispatcher bindings, methods and functionality are more java like though.</p>
* <p>When connecting to the SSIP server the host and port parameters are not defined directly on object creation. Like in the C interface, the {@code SPEECHD_HOST} and {@code SPEECHD_PORT} environment variables are usedd to set this values.
* In addiction, the {@code speechd.host} and {@code speechd.post} properties are checked before the environment variables. There are also default values for fallback when no properties or enviromment variables are set, see {@link SSIPClient#DEFAULT_HOST} and {@link SSIPClient#DEFAULT_PORT}.
* The order (the same for host and port) from first choice to last is:
* <ol>
* <li>Java system properties</li>
* <li>Environment variables</li>
* <li>Default values</li>
* </ol></p>
* <p>the name, component and user values to the constructor have the same meaning as in speech-dispatcher documentation: see {@link SSIPClient#SSIPClient(String, String, String)} for explanation.</p>
* <p>Message priorities are defined when calling speaking methods ({@link SSIPClient#say(SSIPPriority, String)}, {@link SSIPClient#sayChar(SSIPPriority, char)},...) and not directly, although SSIPClient subclasses are allowed to use the {@link SSIPClient#setPriority(SSIPPriority)} method.</p>
* <p>Commands that need a target (like all parameter setting commands) need previous target definition, see @{link {@link SSIPClient#setTarget(Target)} and {@link SSIPClient.Target}. In most cases this feature should not be used, the SELF default is the only needed target most times.
*
* <h4>Example:</h4>
* <code><pre>
* SSIPClient spd = new SSIPClient("myApplication", null, null);
* spd.setVolume(100); //highest volume
* spd.say(SSIPPriority.TEXT, "This is a message."); //speak a message
* spd.close(); //close connection.
* </pre></code>
*
* @author ragb
*
* @see SSIPPriority
* @see SSIPConnection
* @see SSIPEvent
* @see SSIPEventHandler
* @see SSIPException
* @see <a href="http://www.freebsoft.org/doc/speechd">Speech-dispatcher documentation</a>
* @see <a href="http://www.freebsoft.org/doc/speechd/ssip.html">SSIP documentation</a>
*/
public class SSIPClient {
/**
* Enumeration that defines targets for parameter definition (Integer values are allowed for specific client ids).
*
* @author ragb
*
*/
public enum Target {
SELF, ALL
};
/**
* Default host where SSIP server is running.
*/
public static final String DEFAULT_HOST = "localhost";
/**
* Default port where SSIP server is running.
*/
public static final String DEFAULT_PORT = "6560";
/**
* The {@link SSIPConnection} used to handle raw SSIP communication.
*/
private SSIPConnection _connection;
/**
* Target to use when setting parameters, and some other stuff.
*/
private String _target;
/**
* Client name
*/
private String _name;
/**
* Client component
*/
private String _component;
/**
* Connection's user name.
*/
private String _user;
/**
* SSIP server host
*/
private String _host;
/**
* Port where SSIP server is listening
*/
private int _port;
/**
* Client id
*/
private int _clientId;
/**
* LOGGER.
*/
private Logger _logger = Logger.getLogger("speechd.ssip.SSIPClient");
/**
* Constructs a new {@code SSIPClient} and connects it to the SSIP server.
* For setting server host and port see explanation above.
*
* @param name client name.
* @param component Component for this connection, if {@code null} the "main" default value will be used.
* @param user the client user name, if {@code null} the current user name will be used.
* @host hostname to connect to, if {@code null} default mechanism is used
* @port port to connect to, if {@code null} default mechanism applies
* @throws SSIPException when SSIP communication errors are enconterered when connecting to server.
*/
public SSIPClient (String name, String component, String user, String host, String port)
throws SSIPException {
if (name == null) {
throw new NullPointerException("SSIP connection's name can't be null");
} else {
_name = name;
_logger.fine(String.format("Defnining connection's name as %s", _name));
}
// when component is null assign "main" to it (like in c api):
if (component == null) {
_component = "main";
} else {
_component = component;
}
_logger.fine(String.format("Defining connection's component as %s", _component));
// if user is null try to find the current user's name
if (user == null) {
_user = System.getProperty("user.name");
} else {
_user = user;
}
_logger.fine(String.format("Defining user as %s", _user));
// Find host where spd is running:
if ((_host = host) == null) {
if ((_host = System.getProperty("speechd.host")) == null) {
if ((_host = System.getenv("SPEECHD_HOST")) == null)
_host = DEFAULT_HOST;
}
}
_logger.fine(String.format("Defining host as %s", _host));
// Find default port:
String portStr = port;
if (portStr == null) {
if ((portStr = System.getProperty("speechd.port")) == null) {
if ((portStr = System.getenv("SPEECHD_PORT")) == null)
portStr = DEFAULT_PORT;
}
};
_port = Integer.parseInt(portStr);
// create connection and connect it:
_connection = new SSIPConnection(_host, _port);
_connection.connect();
_logger.info("connected to host");
// set connection's name
setTarget(Target.SELF);
setParameter(_target, "client_name", makeFullName());
_logger.fine("Client name set");
// get client self id:
SSIPResponse res = _connection.sendCommand(new SSIPCommand("HISTORY",
"GET", "CLIENT_ID"));
_clientId = getIntResponse(res);
_logger.fine(String.format("Client id is %d", _clientId));
}
/**
* @see java.lang.Object#finalize()
*/
@Override
protected void finalize () throws Throwable {
super.finalize();
close();
}
/**
* Closes smoothly the connection freeing all resources.
* @throws SSIPException on SSIP Errors.
*/
public void close () throws SSIPException {
if (_connection.isConnected()) {
_connection.sendCommand(new SSIPCommand("quit"));
_connection.disconnect();
_logger.info("Disconnected from host");
}
}
/**
* Speaks a message with given priority.
* @param priority message priority
* @param text the message to speak
* @return imessage id of spoken message to be possibly used with callbacks.
* @throws SSIPException on SSIP errors.
* @see SSIPPriority
*/
public int say (SSIPPriority priority, String text) throws SSIPException {
setPriority(priority);
// send speak command:
_logger.info(String.format("Saying message:\n%s", text));
_connection.sendCommand(new SSIPCommand("speak"));
// send data and extract msg id from the response:
SSIPResponse response = _connection.sendData(text);
int id = getIntResponse(response);
_logger.fine(String.format("Message id is %d", id));
return id;
}
/**
* Speaks a formated message with given priority (utility method).
* @param priority message priority
* @param format format string like in {@link String#format(String, Object...)}
* @param args arguments to format
* @return the message id
* @throws SSIPException on SSIP errors.
* @see String#format(String, Object...)
* @see SSIPPriority
*/
public int sayFormated (SSIPPriority priority, String format, Object... args)
throws SSIPException {
return say(priority, String.format(format, args));
}
/**
* Speaks a character representation with given message.
* @param priority the priority
* @param c the character to speak
* @throws SSIPException on SSIP errors.
* @see SSIPPriority
*/
public void sayChar (SSIPPriority priority, char c) throws SSIPException {
String s;
setPriority(priority);
if (c == ' ')
s = "space";
else
s = Character.toString(c);
_logger.info(String.format("Saying character %s", s));
_connection.sendCommand(new SSIPCommand("CHAR", s));
}
/**
* Says given key-name representation. See <a href="http://www.freebsoft.org/doc/speechd/ssip_20.html#SEC36"<key names list</a> for possible key names.
* @param priority the priority
* @param key the key name
* @throws SSIPException on SSIP errors
* @see SSIPPriority
*/
public void sayKey (SSIPPriority priority, String key) throws SSIPException {
setPriority(priority);
_logger.info(String.format("Saying key %s", key));
_connection.sendCommand(new SSIPCommand("KEY", key));
}
/**
* Plays a sound icon. Reffere to <a href="http://www.freebsoft.org/doc/speechd/ssip_21.html#SEC40">Standard sound icons list</a> for the available standard sound icons.
* @param priority the priority
* @param iconName the icon's name
* @throws SSIPException on SSIP errors
* @see SSIPPriority
*/
public void soundIcon (SSIPPriority priority, String iconName)
throws SSIPException {
setPriority(priority);
_logger.info(String.format("Playing sound icon %s", iconName));
_connection.sendCommand(new SSIPCommand("SOUND_ICON", iconName));
}
/**
* Stops speech for current target
* @throws SSIPException on SSIP errors.
*/
public void stop () throws SSIPException {
_logger.info("stopping");
_connection.sendCommand(new SSIPCommand("STOP", _target));
}
/**
* Cancels speech for current target
* @throws SSIPException on SSIp errors
*/
public void cancel () throws SSIPException {
_logger.info("caceling");
_connection.sendCommand(new SSIPCommand("CANCEL", _target));
}
/**
* Pauses speech for current target
* @throws SSIPException on SSIP errors
*/
public void pause () throws SSIPException {
_logger.info("Pausing");
_connection.sendCommand(new SSIPCommand("pause", _target));
}
/**
* Resumes speech for current target
* @throws SSIPException on SSIP errors
*/
public void resume () throws SSIPException {
_logger.info("Pause");
_connection.sendCommand(new SSIPCommand("resume", _target));
}
/**
* Instructs the server to begin a SSIP block.
* @throws SSIPException on SSIP errors
* @see #endBlock()
*/
public void beginBlock () throws SSIPException {
_logger.info("Begin of block");
_connection.sendCommand(new SSIPCommand("BLOCK", "BEGIN"));
}
/**
* INstructs the server to end the current block
* @throws SSIPException on SSIP errors
* @see #beginBlock()
*/
public void endBlock () throws SSIPException {
_logger.info("End of block");
_connection.sendCommand(new SSIPCommand("BLOCK", "END"));
}
/**
* Sets the synthesizer volume.
* @param volume the volume between -100 and 100
* @throws SSIPException on SSIP error
* @throws IllegalArgumentException when value is not in the allowed range
*/
public void setVolume (int volume) throws SSIPException {
verifySynthParameter(volume);
setParameter(_target, "volume", volume);
}
/**
* Sets the speech rate
* @param rate the rate value between -100 and 100.
* @throws SSIPException on SSIP errors
* @throws IllegalArgumentException if {@code rate} value is out of range
*/
public void setRate (int rate) throws SSIPException {
verifySynthParameter(rate);
setParameter(_target, "RATE", rate);
}
/**
* Sets the synthesizer pitch
* @param pitch the pitch to set between -100 and 100.
* @throws SSIPException on SSIP error
* @throws IllegalArgumentException if {@code pitch} is out of range
*/
public void setPitch (int pitch) throws SSIPException {
verifySynthParameter(pitch);
setParameter(_target, "PITCH", pitch);
}
/**
* Sets the output module to use for synthesis. The available output modules depend of system configuration and SSIP Server in use.
* See {@link #getOutputModules()} to find what modules are available
*
* @param module the module name
* @throws SSIPException on error
*/
public void setOutputModule (String module) throws SSIPException {
setParameter(_target, "OUTPUT_MODULE", module);
}
/**
* Sets the language for synthesis. Note that if the language is not available no error is thrown.
* @param language the two letter language code acording to RFC 1766
* @throws SSIPException on SSIP error
*/
public void setLanguage (String language) throws SSIPException {
setParameter(_target, "LANGUAGE", language);
}
/**
* Sets the SSML mode to use
* @param mode {@code true} to activate SSML processing {@code false} to deactivate.
* @throws SSIPException on SSIP error.
*/
public void setSSMLMOde (boolean mode) throws SSIPException {
setParameter(_target, "SSML_MODE", mode);
}
/**
* Defines what punctuation to report, supported values are defined in {@link SSIPPunctuation}.
* @param punctuation the punctuation mode.
* @throws SSIPException on SSIPError
*/
public void setPunctuation (SSIPPunctuation punctuation) throws SSIPException {
setParameter(_target, "PUNCTUATION", punctuation.toString().toLowerCase());
}
/**
* Sets the Spelling mode for synthesis.
* @param spelling {@code true} for spelling, {@code false} for normal speaking.
* @throws SSIPException on SSIP error
*/
public void setSpelling (boolean spelling) throws SSIPException {
setParameter(_target, "SPELLING", spelling);
}
/**
* Sets the voice to use. See <a href="http://www.freebsoft.org/doc/speechd/ssip_22.html#SEC41">Standard voice list</a> to get possible values.
* @param name the voice name
* @throws SSIPException on SSIP error
*/
public void setVoice (String name) throws SSIPException {
setParameter(_target, "VOICE", name);
}
/**
* Sets specific synthesizer voice to use for synthesis. Possible values depend from synthesizer, use {@link #getSynthesisVoices()} to get possible values.
* @param name the voice name
* @throws SSIPException
*/
public void setSynthesisVoice (String name) throws SSIPException {
setParameter(_target, "SYNTHESIS_VOICE", name);
}
/**
* Sets the pause context between sentences, higher the value longer the pause.
* @param n the pause context value between 0 and 100.
* @throws SSIPException on SSIP error
* @throws IllegalArgumentException if {@code n} is out of range.
*/
public void setPauseContext (int n) throws SSIPException {
if (n < 0 || n < 100)
throw new IllegalArgumentException(
"pause context must be positive integer between 0 and 100");
setParameter(_target, "PAUSE_CONTEXT", n);
}
/**
* Sets the capital letters recognition mode, possible values defined in {@link SSIPCapitalLetters}
* @param mode the mode.
* @throws SSIPException
*/
public void setCapitalLettersRecognitionMode(SSIPCapitalLetters mode) throws SSIPException {
setParameter(_target, "CAP_LET_RECOGN", mode.toString().toLowerCase());
}
/**
* Gets the supported output modules. Returned values can be passed to {@link #setOutputModule(String)} to define what module to use.O
* @return the supported output modules as an unmodifiable list of strings.
* @throws SSIPException on SSIP error
*/
public List<String> getOutputModules () throws SSIPException {
_logger.info("Listing output modules");
SSIPResponse res = _connection.sendCommand(new SSIPCommand("LIST",
"OUTPUT_MODULES"));
List<String> ret = getListResponse(res);
_logger.fine(String.format("Output modules are: %s", ret.toString()));
return ret;
}
/**
* Gets the supported voice names. from the standard list ones
* @return the supported voice names as a unmodifiable list of strings.
* @throws SSIPException on SSIP error
*/
public List<String> getVoices () throws SSIPException {
_logger.info("Getting voice names list");
return getListResponse(_connection.sendCommand(new SSIPCommand("LIST",
"VOICES")));
}
/**
* Gets information about all specific voices supported by the synthesizer in use.
* @return the supported voices information as an unmodifiable list of {@link SSIPSynthesisVoice} objects.
* @throws SSIPException on SSIP error.
* @see SSIPSynthesisVoice
*/
public List<SSIPSynthesisVoice> getSynthesisVoices () throws SSIPException {
_logger.info("Getting synthesis voices");
SSIPResponse res = _connection.sendCommand(new SSIPCommand("LIST",
"SYNTHESIS_VOICES"));
List<String> data = getListResponse(res);
// get voice components and construct a list:
List<SSIPSynthesisVoice> voices = new LinkedList<SSIPSynthesisVoice>();
for (String s : data) {
String[] tmp = s.split(" ");
assert (tmp.length == 3);
voices.add(new SSIPSynthesisVoice(tmp[0], tmp[1], tmp[2]));
}
return Collections.unmodifiableList(voices);
}
/**
* Gets the {@code SSIPConnection} this {@code SSIPClient} is using.
* @return the {@code SSIPConnection}
*/
public SSIPConnection getConnection() {
return _connection;
}
/**
* Sets the current target for setting paramenters. allowed values are {@link Target#SELF} and {@link Target#ALL}, see {@link #setTarget(int)} to set targets for specific clients.
* @param target
*/
public void setTarget (Target target) {
_target = target.toString();
}
/**
* Sets the target to a specific client by id.
* @param id the client id
* @see #setTarget(Target)
*/
public void setTarget (int id) {
verifyId(id);
_target = Integer.toString(id);
}
/**
* Sets the {@code SSIPEventHandler} that will receive event notifications for this client.
* @param eventHandler the {@code SSIPEventHandler} to set, <@code null} for no handler.
*/
public void setEventHandler (SSIPEventHandler eventHandler) {
_connection.setEventHandler(eventHandler);
}
/**
* Turns event notification on and off for all event types.
* @param value the value {@code true} to turn on, {@code false} to turn off.
* @throws SSIPException on SSIP error
*/
public void setNotification (boolean value) throws SSIPException {
_connection.sendCommand(new SSIPCommand("SET", Target.SELF.toString(),
"NOTIFICATION", "ALL", value ? "on" : "off"));
}
/**
* Sets event notifications on or off to a specific event type, see {@link SSIPEvent.EventType} for information about event types.
* @param value the value to set {@code true} to set on, {@code false} to turn off.
* @param type the type of the event.
* @throws SSIPException on SSIPError
*/
public void setNotification (boolean value, SSIPEvent.EventType type)
throws SSIPException {
_connection.sendCommand(new SSIPCommand("SET", Target.SELF.toString(),
"NOTIFICATION", type.toString().toUpperCase(), value ? "on" : "off"));
}
/**
* Verifies if {@code id} is an valid id.
* @param id the id to verify
*/
protected void verifyId (int id) {
if (id <= 0)
throw new IllegalArgumentException("client ids must be postivie integers");
}
/**
* Verifies if a parameter is in the allowed range for synth parameters.
* @param param the parameter value
*/
protected void verifySynthParameter (int param) {
if (param > 100 || param < -100)
throw new IllegalArgumentException(
"synth parameters must be between -100 and 100");
}
/**
* Constructs the client full name from its components (name, component and user).
* @return the full name ready to be sent to the set client_name SSIP command
*/
protected String makeFullName () {
return _name + ":" + _component + ":" + _user;
}
/**
* Sets a parameter to a specific target with a string value
* @param target the target
* @param param the parameter name
* @param value the parameter value
* @throws SSIPException on SSIP error
*/
protected void setParameter (String target, String param, String value)
throws SSIPException {
_logger.info(String.format("Setting parameter %s to target %s with value %s", param, target, value));
_connection.sendCommand(new SSIPCommand("set", target, param, value));
}
/**
* Sets a parameter to a specific target with an integer value
* @param target the target
* @param param the parameter name
* @param value the value
* @throws SSIPException on SSIP error
*/
protected void setParameter (String target, String param, int value)
throws SSIPException {
setParameter(target, param, Integer.toString(value));
}
/**
* Sets a parameter to a specific target with a boolean value
* @param target the target
* @param param the parameter to set
* @param value the value
* @throws SSIPException on SSIP error
*/
protected void setParameter (String target, String param, boolean value)
throws SSIPException {
setParameter(target, param, value ? "on" : "off");
}
/**
* Sets priority for the following messages
* @param priority the priority value
* @throws SSIPException on SSIP error
* @see SSIPPriority
*/
protected void setPriority (SSIPPriority priority) throws SSIPException {
setParameter(Target.SELF.toString(), "priority", priority.toString());
}
/**
* Gets the integer value from a {@code SSIP} object.
* @param response the response
* @return the integer value contained in the response
*/
protected int getIntResponse (SSIPResponse response) {
assert (response.getData() != null);
return Integer.parseInt(response.getData().get(0));
}
/**
* Gets the list of data contained on a {@code SSIPResponse} object.
* @param res the response
* @return the data as a unmodifiable list of strings, an empty list if there is no data.
*/
protected List<String> getListResponse (SSIPResponse res) {
List<String> data;
if (res.getData() != null)
data = Collections.unmodifiableList(res.getData());
else
data = Collections.emptyList();
return data;
}
/**
* @return the clientId
*/
public int getClientId () {
return _clientId;
}
}