private Torrent loadTorrent(String res) { ClassLoader cl = this.getClass().getClassLoader(); InputStream is = cl.getResourceAsStream(res); if (is != null) { try { return plugin_interface.getTorrentManager().createFromBEncodedInputStream(is); } catch (Exception e) { Logger.info("System: The channel torrent is impossible to create!"); return null; } } Logger.info("System: The channel torrent created is null"); return null; }
public SalmonContentService(Connection connection, PluginInterface plugin) { messagingManager = new MessagingManager(plugin); messagingManager.addListener(this); try { session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); ingoingQueue = session.createQueue("salmonContentService"); outgoingQueue = session.createQueue("salmonContentResponseService"); producer = session.createProducer(outgoingQueue); producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); consumer = session.createConsumer(ingoingQueue); consumer.setMessageListener(this); } catch (JMSException e) { Logger.error("JMS error: creating Salmon Content service"); } }
@Override public void onMessage(final Message request) { TextMessage textRequest = (TextMessage) request; String text; try { text = textRequest.getText(); Logger.info("Salmon Content service:" + text + ";"); JSONObject record = new JSONObject(text); if (record.has("request")) handleRequest(record); else if (record.has("response")) handleResponse(record); else if (record.has("bullyMessageType") && record.has("action") && record.getString("action").equalsIgnoreCase("send")) handleBullyMessageType(record); } catch (JMSException e1) { e1.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } }