File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
src/main/java/io/ably/tutorial Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import io .ably .lib .realtime .AblyRealtime ;
4
4
import io .ably .lib .realtime .Channel ;
5
+ import io .ably .lib .realtime .CompletionListener ;
5
6
import io .ably .lib .types .AblyException ;
7
+ import io .ably .lib .types .ErrorInfo ;
6
8
import io .ably .lib .types .Message ;
7
9
8
10
public class Example {
@@ -36,5 +38,19 @@ public void onMessage(Message messages) {
36
38
System .out .println ("Message received: " + messages .data );
37
39
}
38
40
});
41
+
42
+ channel .publish ("update" , "new message" , new CompletionListener () {
43
+ @ Override
44
+ public void onSuccess () {
45
+ /* Show success message when message is sent */
46
+ System .out .println ("Message sent" );
47
+ }
48
+
49
+ @ Override
50
+ public void onError (ErrorInfo reason ) {
51
+ /* Show error message when something goes wrong */
52
+ System .out .println ("Message not sent, error occurred: " + reason .message );
53
+ }
54
+ });
39
55
}
40
56
}
You can’t perform that action at this time.
0 commit comments