public void MapRemove(String name, String key, IKVMapListener listener)
        {
            if (!IsConnected())
            {
                throw new Exception("not connected");
            }

            JsonObject envelope = new JsonObject();

            // synchronized to ensure message sequence numbers are ordered
            lock (writeLock)
            {
                long seqNum = Interlocked.Increment(ref messageIdGenerator);

                envelope.Add(ProtocolConstants.OP_FIELD, ProtocolOpConstants.OP_MAP_REMOVE);
                if (qos)
                {
                    envelope.Add(ProtocolConstants.SEQ_NUM_FIELD, seqNum);
                }
                if (name != null)
                {
                    envelope.Add(ProtocolConstants.MAP_FIELD, name);
                }
                if (key != null)
                {
                    envelope.Add(ProtocolConstants.KEY_FIELD, key);
                }

                MapContext ctx = new MapContext(seqNum, envelope.ToString(), key, null, listener);

                requests.Put(seqNum, ctx);

                Queue(ctx);
            }
        }
        public void MapSet(String name, String key, IMessage value, IKVMapListener listener)
        {
            if (!IsConnected())
            {
                throw new Exception("not connected");
            }

            JsonObject envelope = new JsonObject();

            // synchronized to ensure message sequence numbers are ordered
            lock (writeLock)
            {
                long seqNum = Interlocked.Increment(ref messageIdGenerator);

                envelope.Add(ProtocolConstants.OP_FIELD, ProtocolOpConstants.OP_MAP_SET);
                if (qos)
                {
                    envelope.Add(ProtocolConstants.SEQ_NUM_FIELD, seqNum);
                }
                if (name != null)
                {
                    envelope.Add(ProtocolConstants.MAP_FIELD, name);
                }
                if (key != null)
                {
                    envelope.Add(ProtocolConstants.KEY_FIELD, key);
                }
                if (value != null)
                {
                    envelope.Add(ProtocolConstants.VALUE_FIELD, ((JSONMessage)value)._rawData());
                }

                MapContext ctx = new MapContext(seqNum, envelope.ToString(), key, value, listener);

                if (maxMessageSize > 0 && ctx.GetJson().Length > maxMessageSize)
                {
                    throw new Exception("maximum message size exceeded");
                }

                requests.Put(seqNum, ctx);

                Queue(ctx);
            }
        }
Ejemplo n.º 3
0
 public void Remove(String key, IKVMapListener listener)
 {
     conn.MapRemove(name, key, listener);
 }
Ejemplo n.º 4
0
 public void Get(String key, IKVMapListener listener)
 {
     conn.MapGet(name, key, listener);
 }
Ejemplo n.º 5
0
 public void Set(String key, IMessage value, IKVMapListener listener)
 {
     conn.MapSet(name, key, value, listener);
 }
Ejemplo n.º 6
0
 internal MapContext(Int64 seqNum, String json, String key, IKVMapListener listener) : base(seqNum, json)
 {
     this.key      = key;
     this.listener = listener;
 }
Ejemplo n.º 7
0
 internal MapListener(String key, IMessage value, IKVMapListener listener)
 {
     this.key      = key;
     this.value    = value;
     this.listener = listener;
 }
Ejemplo n.º 8
0
 internal MapContext(Int64 seqNum, String json, String key, IKVMapListener listener) : base(seqNum, json, (listener != null ? new MapListener(key, null, listener) : null))
 {
 }