private void notifyChanges() { if (notificationListener != null) { notificationListener.announce(notificationChannel, notificationInstanceId); } }
public void subscribe(String channel) { subscribedChannels.add(channel); logger.log(Level.INFO, "Subscribing to channel " + channel + "..."); sendMessageOrAddToOutgoingQueue(String.format("subscribe %s\n", channel)); }
private void startNotificationListener() { logger.log(Level.INFO, "Starting notification listener for " + config.getLocalDir() + " ..."); notificationListener = new NotificationListener(options.getAnnouncementsHost(), options.getAnnouncementsPort(), this); notificationListener.start(); notificationListener.subscribe(notificationChannel); }
public void start() { logger.log(Level.INFO, "Starting notification listener thread ..."); stop(); incomingMessageThread = new SocketThread(); incomingMessageThread.start(); }
private void sendMessageOrAddToOutgoingQueue(String message) { if (connected.get()) { try { socketOut.write(StringUtil.toBytesUTF8(message)); logger.log(Level.INFO, "Sent message: " + message.trim()); } catch (IOException e) { logger.log(Level.FINE, "Could write to the socket", e); queueOutgoingMessage(message); } } else { queueOutgoingMessage(message); } }
private void connect() { try { logger.log(Level.INFO, "Connecting socket to " + host + ":" + port + " ..."); socket = new Socket(host, port); socket.setSoTimeout(SOCKET_TIMEOUT); socketOut = socket.getOutputStream(); socketIn = new BufferedReader(new InputStreamReader(socket.getInputStream())); connected.set(socket.isConnected()); } catch (IOException e) { logger.log(Level.FINE, "Could not connect the socket", e); disconnect(); } }
subscribe(channel);
private void stopNotificationListener() { logger.log(Level.INFO, "Stopping notification listener for " + config.getLocalDir() + " ..."); notificationListener.stop(); }
public void announce(String channel, String message) { logger.log(Level.INFO, "Announcing to channel " + channel + ": " + message.trim()); sendMessageOrAddToOutgoingQueue(String.format("announce %s %s\n", channel, message)); }
public void unsubscribe(String channel) { subscribedChannels.remove(channel); logger.log(Level.INFO, "Unsubscribing from channel " + channel + "..."); sendMessageOrAddToOutgoingQueue(String.format("unsubscribe %s\n", channel)); }