package com.juick.jabber.ws; import java.nio.ByteBuffer; import java.nio.channels.SocketChannel; /** * * @author ugnich */ public class SocketSubscribed { public SocketChannel sock = null; public String clientName = null; public int VUID = 0; public int UID = 0; public int MID = 0; public boolean allMessages = false; public boolean allReplies = false; public long tsConnected; public long tsLastData; public SocketSubscribed(SocketChannel sock, String clientName, int VUID) { this.sock = sock; this.clientName = clientName; this.VUID = VUID; tsConnected = tsLastData = System.currentTimeMillis(); } public boolean sendByteBuffer(ByteBuffer bb) { boolean ret = false; bb.rewind(); try { sock.write(bb); ret = true; } catch (Exception e) { close(); } return ret; } public void close() { try { sock.socket().close(); } catch (Exception e) { } try { sock.close(); } catch (Exception e) { } } }