Esempio n. 1
0
        public override bool Equals(object obj)
        {
            SetWatches peer = (SetWatches)obj;

            if (peer == null)
            {
                return(false);
            }
            if (Object.ReferenceEquals(peer, this))
            {
                return(true);
            }
            bool ret = false;

            ret = (RelativeZxid == peer.RelativeZxid);
            if (!ret)
            {
                return(ret);
            }
            ret = DataWatches.Equals(peer.DataWatches);
            if (!ret)
            {
                return(ret);
            }
            ret = ExistWatches.Equals(peer.ExistWatches);
            if (!ret)
            {
                return(ret);
            }
            ret = ChildWatches.Equals(peer.ChildWatches);
            if (!ret)
            {
                return(ret);
            }
            return(ret);
        }
        private void PrimeConnection()
        {
            #if !NET_CORE
            LOG.InfoFormat("Socket connection established to {0}, initiating session", client.Client.RemoteEndPoint);
            #endif
            ConnectRequest conReq = new ConnectRequest(0, lastZxid, Convert.ToInt32(conn.SessionTimeout.TotalMilliseconds), conn.SessionId, conn.SessionPassword);

            lock (outgoingQueue)
            {
                if (!ClientConnection.DisableAutoWatchReset && (!zooKeeper.DataWatches.IsEmpty() || !zooKeeper.ExistWatches.IsEmpty() || !zooKeeper.ChildWatches.IsEmpty()))
                {
                    var sw = new SetWatches(lastZxid, zooKeeper.DataWatches, zooKeeper.ExistWatches, zooKeeper.ChildWatches);
                    var h = new RequestHeader();
                    h.Type = (int)OpCode.SetWatches;
                    h.Xid = -8;
                    Packet packet = new Packet(h, new ReplyHeader(), sw, null, null, null, null, null);
                    //outgoingQueue.AddFirst(packet);
                    addPacketFirst(packet);
                }

                foreach (ClientConnection.AuthData id in conn.authInfo)
                    addPacketFirst(
                        new Packet(new RequestHeader(-4, (int)OpCode.Auth), null, new AuthPacket(0, id.Scheme, id.GetData()), null, null, null, null, null));

                addPacketFirst(new Packet(null, null, conReq, null, null, null, null, null));

            }
            packetAre.Set();
            #if !NET_CORE
            if (LOG.IsDebugEnabled)
                LOG.DebugFormat("Session establishment request sent on {0}", client.Client.RemoteEndPoint);
            #endif
        }