예제 #1
0
        private void netsoul_OnContactUpdate(object sender, NetSoulContactUpdateEventArgs e)
        {
            var contact = this.Contacts.Where(c => c.Login == e.Contact.Login).FirstOrDefault();

            if (contact != null)
            {
                this.disp.Invoke(() =>
                {
                    contact.Status     = e.Contact.Status;
                    contact.Location   = e.Contact.Location;
                    contact.UserSocket = e.Contact.UserSocket;
                });
            }
            else
            {
                if (e.Contact.Status != ContactStatus.Offline)
                {
                    var c = new Contact();
                    c.Login      = e.Contact.Login;
                    c.Location   = e.Contact.Location;
                    c.Status     = e.Contact.Status;
                    c.UserData   = e.Contact.UserData;
                    c.UserSocket = e.Contact.UserSocket;
                    this.disp.Invoke(() =>
                    {
                        this.Contacts.Add(c);
                    });
                }
            }
        }
예제 #2
0
파일: Netsoul.cs 프로젝트: Laxyus/Netsoul
        /// <summary>
        /// Create the NetSoulContactUpdateEventArgs and raises OnContactUpdated when a WHO command is received
        /// </summary>
        /// <param name="login">Login of the concerned contact</param>
        /// <param name="status">State of the concerned contact</param>
        /// <param name="location">Location of the concerned contact</param>
        /// <param name="userdata">UserData of the concerned contact</param>
        /// <param name="socket">Socket of the concerned contact</param>
        private void UpdateContact(string login, string status, string location, string userdata, string socket)
        {
            NetSoulContactUpdateEventArgs e = new NetSoulContactUpdateEventArgs("update:" + login + ":" + status + ":" + location + ":" + userdata + ":" + socket);

            if (this.OnContactUpdated != null)
            {
                this.OnContactUpdated(this, e);
            }
        }
예제 #3
0
 async void NetSoul_OnContactUpdated(object sender, NetSoulContactUpdateEventArgs e)
 {
     //string[] update = e.UpdatedContact.Split(':');
     //switch (update[0])
     //{
     //    case "update":
     //        await this.UpdateContact(update);
     //        break;
     //    case "logout":
     //        this.LogOutContact(update);
     //        break;
     //    case "state":
     //        this.UpdateStateContact(update);
     //        break;
     //    default:
     //        break;
     //}
 }
예제 #4
0
파일: Netsoul.cs 프로젝트: Laxyus/Netsoul
        /// <summary>
        /// Create the NetSoulContactUpdateEventArgs and raises OnContactUpdated when a change of state occurs
        /// </summary>
        /// <param name="Event">Type of change of state</param>
        /// <param name="login">Login of the concerned contact</param>
        /// <param name="socket">Socket of the concerned contact</param>
        /// <param name="data">New state of the concerned contact (in case of logout event, data is null)</param>
        private void LogUpdate(string Event, string login, string socket, string data)
        {
            NetSoulContactUpdateEventArgs e = null;

            switch (Event)
            {
            case "logout":
                e = new NetSoulContactUpdateEventArgs("logout:" + login + ":" + socket);
                break;

            case "state":
                e = new NetSoulContactUpdateEventArgs("state:" + login + ":" + socket + ":" + data);
                break;

            default:
                break;
            }
            if (this.OnContactUpdated != null && e != null)
            {
                this.OnContactUpdated(this, e);
            }
        }