+ if (backend.hasEvents()) {
+ backend.getEvents(queue);
+
+ // This default backend assumes a single user, and if that
+ // user becomes disconnected we should terminate the
+ // application.
+ if (queue.size() > 0) {
+ TInputEvent event = queue.get(queue.size() - 1);
+ if (event instanceof TCommandEvent) {
+ TCommandEvent command = (TCommandEvent) event;
+ if (command.equals(cmBackendDisconnect)) {
+ if (backendsToRemove == null) {
+ backendsToRemove = new ArrayList<Backend>();
+ }
+ backendsToRemove.add(backend);
+ }
+ }
+ }
+ }
+ }
+ if (backendsToRemove != null) {
+ for (Backend backend: backendsToRemove) {
+ multiScreen.removeScreen(backend.getScreen());
+ backends.remove(backend);
+ backend.shutdown();
+ }
+ }
+ if (backends.size() == 0) {
+ queue.add(new TCommandEvent(cmAbort));