Example #1
0
        private void OnAddressReceive(AddressNotification n)
        {
            // ignore if it is my address
            if (n.Address == Address)
            {
                return;
            }

            if (n.Reason == NotifyReason.Death)
            {
                if (addressList.ContainsKey(n.Address))
                {
                    RemoveAddress(n.Address);
                }
                else
                {
                    Log("Dummy death address notification received from " + n.Address, LogLevel.Minor);
                }
            }
            else
            {
                if (!addressList.ContainsKey(n.Address))
                {
                    // add the received address to the addressList
                    addressList.Add(n.Address, n.TissueType);
                    Log("Found agent " + n.Address, LogLevel.Minor);

                    // inform the sender of me
                    Mediator.Send(OnAddressReceive, n.Address, 0,
                                  new AddressNotification(Address, ((ITissue)this).Type, NotifyReason.Birth));
                }
            }
        }
Example #2
0
		private void OnAddressReceive(AddressNotification n)
		{
			// ignore if it is my address
			if (n.Address == Address)
			{
				return;
			}

			if (n.Reason == NotifyReason.Death)
			{
				if (addressList.ContainsKey(n.Address))
				{
					RemoveAddress(n.Address);
				}
				else
				{
					Log("Dummy death address notification received from " + n.Address, LogLevel.Minor);
				}
			}
			else
			{
				if (!addressList.ContainsKey(n.Address))
				{
					// add the received address to the addressList
					addressList.Add(n.Address, n.TissueType);
					Log("Found agent " + n.Address, LogLevel.Minor);

					// inform the sender of me
					Mediator.Send(OnAddressReceive, n.Address, 0, 
						new AddressNotification(Address, ((ITissue)this).Type, NotifyReason.Birth));
				}
			}
		}