aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/jabber/ws/SocketSubscribed.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-01-16 16:43:43 +0300
committerGravatar Vitaly Takmazov2016-01-16 16:43:43 +0300
commite746ca6970bea80ec9b5ae79dda8f6332254e301 (patch)
tree92c354060fa03c5f781804ba1e38114a0a8af45c /src/main/java/com/juick/jabber/ws/SocketSubscribed.java
parent694bc7b9dd4f3e7d0a918ddb2327dbb676fc6465 (diff)
moved to Gradle
Diffstat (limited to 'src/main/java/com/juick/jabber/ws/SocketSubscribed.java')
-rw-r--r--src/main/java/com/juick/jabber/ws/SocketSubscribed.java51
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) {
+ }
+ }
+}