public Constants.LoginStatus logon(User user)
		{
			Constants.LoginStatus retval = Constants.LoginStatus.STATUS_SERVERNOTREACHED;
			byte[] message = new byte[Constants.WRITEBUFFSIZE];
			byte[] reply;
			MemoryStream stream = new MemoryStream(message);

			try
			{
				//Serialize data in memory so you can send them as a continuous stream
				BinaryFormatter serializer = new BinaryFormatter();
				
				NetLib.insertEntropyHeader(serializer, stream);

				serializer.Serialize(stream, Constants.MessageTypes.MSG_LOGIN);
				serializer.Serialize(stream, user.ringsInfo[0].ring.ringID);
				serializer.Serialize(stream, user.ringsInfo[0].userName);
				serializer.Serialize(stream, user.ringsInfo[0].password);
				serializer.Serialize(stream, user.node.syncCommunicationPoint);
				reply = NetLib.communicate(Constants.SERVER2,message, true);
				stream.Close();
				stream = new MemoryStream(reply);
				NetLib.bypassEntropyHeader(serializer, stream);
				Constants.MessageTypes replyMsg = (Constants.MessageTypes)serializer.Deserialize(stream);

				switch(replyMsg)
				{
					case Constants.MessageTypes.MSG_OK:
						ulong sessionID = (ulong)serializer.Deserialize(stream);
						uint numRings = (uint)serializer.Deserialize(stream);
						uint ringID;
						Ring ring;
						for(uint ringCounter = 0; ringCounter < numRings; ringCounter++)
						{
							LordInfo lordInfo = (LordInfo)serializer.Deserialize(stream);
							ring = RingInfo.findRingByID(user.ringsInfo, lordInfo.ringID);
							ring.lords = lordInfo.lords;
						}
						
						user.loggedIn = true;
						retval = Constants.LoginStatus.STATUS_LOGGEDIN;
						break;
					case Constants.MessageTypes.MSG_NOTAMEMBER:
						retval = Constants.LoginStatus.STATUS_NOTAMEMBER;
						break;
					case Constants.MessageTypes.MSG_ALREADYSIGNEDIN:
						retval = Constants.LoginStatus.STATUS_ALREADYSIGNEDIN;
						break;
					default:
						break;
				}
			}
			catch (Exception e)
			{
				
				int x = 2;
			}

			return retval;
		}
        public void logoff(User user)
        {
            byte[] message = new byte[Constants.WRITEBUFFSIZE];
            MemoryStream stream = null;

            if(!loggedIn)
                return;
            try
            {
                //Serialize data in memory so you can send them as a continuous stream
                BinaryFormatter serializer = new BinaryFormatter();
                stream = new MemoryStream(message);
                serializer.Serialize(stream, Constants.MessageTypes.MSG_LOGOFF);
                serializer.Serialize(stream, this.loginCallbackTable.getSessionID());
                serializer.Serialize(stream, user.publicUserInfo);
                serializer.Serialize(stream, user.privateUserInfo);
                serializer.Serialize(stream, user.node);
                NetLib.communicate(Constants.SERVER,message, false);
                stream.Close();
            }
            catch
            {
                return;
            }
            finally
            {
                loggedIn = false;
            }
        }
		public void syncUserInfo(User user)
		{
			byte[] message = new byte[Constants.WRITEBUFFSIZE];
			MemoryStream stream;

			try 
			{
				//Serialize data in memory so you can send them as a continuous stream
				BinaryFormatter serializer = new BinaryFormatter();
				stream = new MemoryStream(message);
				serializer.Serialize(stream, Constants.MessageTypes.MSG_SYNCUSRINFO);
				serializer.Serialize(stream, sessionID);
				serializer.Serialize(stream, user);
				NetLib.communicate(Constants.SERVER, message, false);
			}
			catch
			{
			}
		}
        public Constants.LoginStatus login(User user)
        {
            Constants.LoginStatus retval = Constants.LoginStatus.STATUS_SERVERNOTREACHED;

            while(!user.loggedIn&& numLoginRetries < Constants.MAXLOGINRETRIES)
            {
                retval = serverProxy.logon(user);
                switch(retval)
                {
                    case Constants.LoginStatus.STATUS_SERVERNOTREACHED:
                        //sleep and retry logging in
                        Thread.Sleep(Constants.LOGINRETRYINTERVAL);
                        break;
                    default:
                        break;
                }
                numLoginRetries++;
            }
            return retval;
        }
		public bool signup(User user)
		{
			return true;
		}
 public bool isSameAs(User another)
 {
     return true;
 }
 public static void setInstance(User _user)
 {
     userinstance = _user;
 }
        public static User getInstance()
        {
            //singleton pattern
            if(userinstance == null)
            {
                //REVISIT: needs to get the file ptr from global client configurationManager
                XmlReader reader = new XmlTextReader(@"..\..\..\ResourceRingServer\bin\Debug\accounts.xml");
                XmlSerializer deserializer = new XmlSerializer(typeof(Member[]));
                Member[] existingMembers = (Member[])deserializer.Deserialize(reader);
                reader.Close();

                Random randomizer = new Random(System.DateTime.Now.Millisecond);
                Member member = existingMembers[randomizer.Next()%existingMembers.Length];
                userinstance = User.memberToUser(member);
                userinstance.ringsInfo = Constants.DEFAULT_RINGSINFO;

                foreach (RingInfo ringInfo in userinstance.ringsInfo)
                {
                    ringInfo.userName = member.userName;
                    ringInfo.password = member.password;
                    ringInfo.IE = new InformationEntropy[1];
                    ringInfo.IE[0] = new InformationEntropy(ringInfo.ring.ringName, 1.0f);
                }
            }
            return userinstance;
        }
        public Constants.LoginStatus logon(User user)
        {
            Constants.LoginStatus retval = Constants.LoginStatus.STATUS_SERVERNOTREACHED;
            byte[] message = new byte[Constants.WRITEBUFFSIZE];
            byte[] reply;
            MemoryStream stream = null;

            try
            {
                //Serialize data in memory so you can send them as a continuous stream
                BinaryFormatter serializer = new BinaryFormatter();
                stream = new MemoryStream(message);
                NetLib.insertEntropyHeader(serializer, stream);

                serializer.Serialize(stream, Constants.MessageTypes.MSG_LOGIN);
                serializer.Serialize(stream, user.ringsInfo[0].userName);
                serializer.Serialize(stream, user.ringsInfo[0].password);
                serializer.Serialize(stream, user.node);
                reply = NetLib.communicate(Constants.SERVER,message, true);
                stream.Close();
                stream = new MemoryStream(reply);
                Constants.MessageTypes replyMsg = (Constants.MessageTypes)serializer.Deserialize(stream);

                switch(replyMsg)
                {
                    case Constants.MessageTypes.MSG_OK:
                        retval = Constants.LoginStatus.STATUS_LOGGEDIN;
                        ulong sessionID = (ulong)serializer.Deserialize(stream);
                        int numAdjPeers = (int)serializer.Deserialize(stream);
                        Peer[] adjPeers = null;
                        if(numAdjPeers > 0)
                        {
                            adjPeers = new Peer[numAdjPeers];
                            adjPeers = (Peer[])serializer.Deserialize(stream);
                        }

                        //add the adjacent peers reported to our list (callback to Client)
                        this.loginCallbackTable.addAdjacentPeers(adjPeers);
                        loggedIn = true;

                        //set the session ID (callback to ServerProxy)
                        this.loginCallbackTable.setSessionID(sessionID);
                        break;
                    case Constants.MessageTypes.MSG_NOTAMEMBER:
                        retval = Constants.LoginStatus.STATUS_NOTAMEMBER;
                        break;
                    case Constants.MessageTypes.MSG_ALREADYSIGNEDIN:
                        retval = Constants.LoginStatus.STATUS_ALREADYSIGNEDIN;
                        break;
                    default:
                        break;
                }
            }
            catch (Exception e)
            {

                int x = 2;
            }

            return retval;
        }
 private void signup(User user)
 {
     serverProxy.signup(user);
 }