Inheritance: GablarskiMessage
        public void JoinWithServerPassword()
        {
            string nickname = "Foo";
            string password = "******";
            var msg = new JoinMessage { Nickname = nickname, ServerPassword = password };
            Assert.AreEqual (nickname, msg.Nickname);
            Assert.AreEqual (password, msg.ServerPassword);
            msg.WritePayload (null, writer);
            long length = stream.Position;
            stream.Position = 0;

            msg = new JoinMessage();
            msg.ReadPayload (null, reader);

            Assert.AreEqual (length, stream.Position);
            Assert.AreEqual (nickname, msg.Nickname);
            Assert.AreEqual (password, msg.ServerPassword);
        }
        public void Join()
        {
            string nickname = "Foo";
            var msg = new JoinMessage { Nickname = nickname };
            msg.WritePayload (null, writer);
            long length = stream.Position;
            stream.Position = 0;

            msg = new JoinMessage();
            msg.ReadPayload (null, reader);

            Assert.AreEqual (length, stream.Position);
            Assert.AreEqual (nickname, msg.Nickname);
        }
Exemple #3
0
		private IUserInfo GetJoiningUserInfo (IConnection connection, JoinMessage join)
		{
			if (!Manager.GetIsConnected (connection))
			{
				connection.SendAsync (new JoinResultMessage (LoginResultState.FailedNotConnected, null));
				return null;
			}

			IUserInfo info = this.Manager.GetUser (connection);

			if (info == null)
			{
				if (!this.context.Settings.AllowGuestLogins)
				{
					connection.SendAsync (new JoinResultMessage (LoginResultState.FailedUsername, null));
					return null;
				}

				LoginResult r = this.context.UserProvider.Login (join.Nickname, null);
				if (!r.Succeeded)
				{
					connection.SendAsync (new JoinResultMessage (r.ResultState, null));
					return null;
				}

				info = new UserInfo (join.Nickname, join.Phonetic, join.Nickname, r.UserId, this.context.ChannelsProvider.DefaultChannel.ChannelId, false);
			}
			else
				info = new UserInfo (join.Nickname, join.Phonetic, info);

			return info;
		}