diff options
Diffstat (limited to 'src/main/java/com/juick/jabber/ws/SocketSubscribed.java')
-rw-r--r-- | src/main/java/com/juick/jabber/ws/SocketSubscribed.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/main/java/com/juick/jabber/ws/SocketSubscribed.java b/src/main/java/com/juick/jabber/ws/SocketSubscribed.java new file mode 100644 index 00000000..6144380c --- /dev/null +++ b/src/main/java/com/juick/jabber/ws/SocketSubscribed.java @@ -0,0 +1,51 @@ +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) { + } + } +} |