Exemplo n.º 1
0
        public void UserChangedChannelWithoutRequesting()
        {
            var changeInfo = new ChannelChangeInfo (1, 2, 1);
            var msg = new UserChangedChannelMessage { ChangeInfo = changeInfo };
            Assert.AreEqual (changeInfo.TargetUserId, msg.ChangeInfo.TargetUserId);
            Assert.AreEqual (changeInfo.TargetChannelId, msg.ChangeInfo.TargetChannelId);
            Assert.AreEqual (changeInfo.PreviousChannelId, msg.ChangeInfo.PreviousChannelId);
            Assert.AreEqual (changeInfo.RequestingUserId, msg.ChangeInfo.RequestingUserId);
            msg.WritePayload (serverContext, writer);
            long length = stream.Position;
            stream.Position = 0;

            msg = new UserChangedChannelMessage();
            msg.ReadPayload (clientContext, reader);
            Assert.AreEqual (length, stream.Position);
            Assert.AreEqual (changeInfo.TargetUserId, msg.ChangeInfo.TargetUserId);
            Assert.AreEqual (changeInfo.TargetChannelId, msg.ChangeInfo.TargetChannelId);
            Assert.AreEqual (changeInfo.PreviousChannelId, msg.ChangeInfo.PreviousChannelId);
            Assert.AreEqual (changeInfo.RequestingUserId, msg.ChangeInfo.RequestingUserId);
        }
Exemplo n.º 2
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     this.ChangeInfo = new ChannelChangeInfo(context, reader);
 }
Exemplo n.º 3
0
        public ReceivedChannelChannelResultEventArgs(ChannelChangeInfo moveInfo, ChannelChangeResult result)
        {
            if (moveInfo == null)
                throw new ArgumentNullException ("moveInfo");

            this.MoveInfo = moveInfo;
            this.Result = result;
        }
Exemplo n.º 4
0
 public ChannelChangeResultMessage(ChannelChangeResult result, ChannelChangeInfo moveInfo)
     : this()
 {
     this.Result   = result;
     this.MoveInfo = moveInfo;
 }
Exemplo n.º 5
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     this.Result   = (ChannelChangeResult)reader.ReadByte();
     this.MoveInfo = new ChannelChangeInfo(context, reader);
 }
Exemplo n.º 6
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     this.ChangeInfo = new ChannelChangeInfo (context, reader);
 }
Exemplo n.º 7
0
		public void Move (IUserInfo user, IChannelInfo channel)
		{
			if (user == null)
				throw new ArgumentNullException ("user");
			if (channel == null)
				throw new ArgumentNullException ("channel");

			int previousChannel = user.CurrentChannelId;
			if (previousChannel == channel.ChannelId)
				return;

			IUserInfo realUser = this[user.UserId];
			if (realUser == null)
				return;

			IChannelInfo realChannel = context.Channels[channel.ChannelId];
			if (realChannel == null)
				return;

			var changeInfo = new ChannelChangeInfo (user.UserId, channel.ChannelId, previousChannel);

			int numUsers = context.Users.Count (u => u.CurrentChannelId == channel.ChannelId);
			if (channel.UserLimit != 0 && numUsers >= channel.UserLimit)
				return;

			Manager.Move (realUser, realChannel);

			foreach (var connection in Manager.GetConnections())
				connection.SendAsync (new UserChangedChannelMessage { ChangeInfo = changeInfo });
		}
Exemplo n.º 8
0
 public ChannelChangeResultMessage(ChannelChangeResult result, ChannelChangeInfo moveInfo)
     : this()
 {
     this.Result = result;
     this.MoveInfo = moveInfo;
 }