Example #1
0
 public void RevokeIncomingInvite(RemotePlayer source)
 {
     lock (this.IncomingInvites)
     {
         if (this.IncomingInvites.Remove(source.ID))
         {
             this.Connection.Send(new S2C_RevokedIncomingPlayerInvite(source.GetDisplay()));
             source.RevokeSentInvite(this);
         }
     }
 }
Example #2
0
 public void RevokeSentInvite(RemotePlayer destination)
 {
     lock (this.SentInvites)
     {
         if (this.SentInvites.Remove(destination.ID))
         {
             Connection.Send(new S2C_RevokedSentPlayerInvite(destination.GetDisplay()));
             destination.RevokeIncomingInvite(this);
         }
     }
 }
Example #3
0
        protected void ReceiveIncomingInvite(RemotePlayer source)
        {
            bool added = false;

            lock (this.IncomingInvites)
            {
                if (!this.IncomingInvites.ContainsKey(source.ID))
                {
                    this.IncomingInvites.Add(source.ID, source);
                    added = true;
                }
            }
            if (added)
            {
                this.Connection.Send(new S2C_IncomingPlayerInvite(source.GetDisplay()));
            }
        }
Example #4
0
        //private void IncomingInvites_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        //{
        //    //inbox
        //    if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
        //    {
        //        foreach (var from in e.NewItems)
        //        {
        //            this.Connection.Send(new S2C_IncomingPlayerInvite(from as RemotePlayer));
        //        }

        //    }
        //    else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
        //    {
        //        foreach (var from in e.OldItems)
        //        {
        //            this.Connection.Send(new S2C_RevokedIncomingPlayerInvite((from as RemotePlayer).Connection.ConnectionInfo.NetworkIdentifier));
        //        }
        //    }
        //}

        //private void SentInvites_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        //{
        //    //outbox
        //    if(e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
        //    {
        //        foreach (var target in e.NewItems)
        //        {
        //            (target as RemotePlayer).IncomingInvites.Add(this);
        //            //S2C_SentPlayerInvite
        //        }

        //    }
        //    else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
        //    {
        //        foreach(var target in e.OldItems)
        //        {
        //            (target as RemotePlayer).IncomingInvites.Remove(this);
        //            //S2C_RevokeSentPlayerInvite
        //        }
        //    }
        //}

        /// <summary>
        /// Send a game invite.
        /// </summary>
        /// <param name="player2">Invitation target</param>
        public void SendInvite(RemotePlayer destination)
        {
            bool added = false;

            lock (this.SentInvites)
            {
                if (!this.SentInvites.ContainsKey(destination.ID))
                {
                    this.SentInvites.Add(destination.ID, destination);
                    added = true;
                }
            }
            if (added)
            {
                destination.ReceiveIncomingInvite(this);
                Connection.Send(new S2C_SentPlayerInvite(destination.GetDisplay()));
            }
        }