OpenMetaverse.FriendsManager.OnlineNotificationHandler C# (CSharp) Method

OnlineNotificationHandler() private method

Handle notifications sent when a friends has come online.
private OnlineNotificationHandler ( Packet packet, Simulator simulator ) : void
packet OpenMetaverse.Packets.Packet
simulator Simulator
return void
        private void OnlineNotificationHandler(Packet packet, Simulator simulator)
        {
            if (packet.Type == PacketType.OnlineNotification)
            {
                OnlineNotificationPacket notification = ((OnlineNotificationPacket)packet);

                foreach (OnlineNotificationPacket.AgentBlockBlock block in notification.AgentBlock)
                {
                    FriendInfo friend;

                    lock (FriendList)
                    {
                        if (!FriendList.ContainsKey(block.AgentID))
                        {
                            friend = new FriendInfo(block.AgentID, FriendRights.CanSeeOnline,
                                FriendRights.CanSeeOnline);
                            FriendList.Add(block.AgentID, friend);
                        }
                        else
                        {
                            friend = FriendList[block.AgentID];
                        }
                    }

                    bool doNotify = !friend.IsOnline;
                    friend.IsOnline = true;

                    if (OnFriendOnline != null && doNotify)
                    {
                        try { OnFriendOnline(friend); }
                        catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
                    }
                }
            }
        }