@Override public int hashCodeForPacket(Packet packet) { if (packet.getStanzaTo() != null) { return packet.getStanzaTo().hashCode(); } if (packet.getTo() != null) { return packet.getTo().hashCode(); } return super.hashCodeForPacket(packet); }
/** * Method description * * @param ios * @param p * @return a value of <code>boolean</code> */ public boolean writePacketToSocket(IO ios, Packet p) { if (ios != null) { if (log.isLoggable(Level.FINER) && !log.isLoggable(Level.FINEST)) { log.log( Level.FINER, "{0}, Processing packet: {1}, type: {2}", new Object[] {ios, p.getElemName(), p.getType()}); } if (log.isLoggable(Level.FINEST)) { log.log(Level.FINEST, "{0}, Writing packet: {1}", new Object[] {ios, p}); } // synchronized (ios) { ios.addPacketToSend(p); if (ios.writeInProgress.tryLock()) { try { ios.processWaitingPackets(); SocketThread.addSocketService(ios); return true; } catch (Exception e) { log.log(Level.WARNING, ios + "Exception during writing packets: ", e); try { ios.stop(); } catch (Exception e1) { log.log(Level.WARNING, ios + "Exception stopping XMPPIOService: ", e1); } // end of try-catch } finally { ios.writeInProgress.unlock(); } } } else { if (log.isLoggable(Level.FINE)) { log.log( Level.FINE, "Can''t find service for packet: <{0}> {1}, service id: {2}", new Object[] {p.getElemName(), p.getTo(), getServiceId(p)}); } } // end of if (ios != null) else return false; }
/** * Method description * * @param packet * @return a value of <code>String</code> */ protected String getServiceId(Packet packet) { return getServiceId(packet.getTo()); }