Example #1
0
        protected virtual void OnWinkDefinitionReceived(object sender, WinkEventArgs e)
        {
            if (!autoRequestObjects)
            {
                return;
            }

            MSNObject existing = MSNObjectCatalog.GetInstance().Get(e.Wink.CalculateChecksum());

            if (existing == null)
            {
                // create a session and send the invitation
                ObjectTransfer winkTransfer = nsMessageHandler.P2PHandler.RequestMsnObject(e.Sender, e.Wink);
                winkTransfer.TransferAborted  += (winkTransfer_TransferAborted);
                winkTransfer.TransferFinished += (winkTransfer_TransferFinished);

                MSNObjectCatalog.GetInstance().Add(e.Wink);

                if (WinkDefinitionReceived != null)
                {
                    WinkDefinitionReceived(this, e);
                }
            }
            else
            {
                if (WinkDefinitionReceived != null)
                {
                    WinkDefinitionReceived(this, new WinkEventArgs(e.Sender, existing as Wink, e.RoutingInfo));
                }

                //If exists, fire the event.
                OnWinkReceived(this, new WinkEventArgs(e.Sender, existing as Wink, e.RoutingInfo));
            }
        }
Example #2
0
        /// <summary>
        /// Updates the msn object in the global MSNObjectCatalog.
        /// </summary>
        public void UpdateInCollection()
        {
            if (oldHash.Length != 0)
            {
                MSNObjectCatalog.GetInstance().Remove(oldHash);
            }

            oldHash = CalculateChecksum();

            MSNObjectCatalog.GetInstance().Add(oldHash, this);
        }
Example #3
0
        protected virtual void OnEmoticonDefinitionReceived(object sender, EmoticonDefinitionEventArgs e)
        {
            if (!autoRequestObjects)
            {
                return;
            }

            MSNObject existing = MSNObjectCatalog.GetInstance().Get(e.Emoticon.CalculateChecksum());

            if (existing == null)
            {
                e.Sender.Emoticons[e.Emoticon.Sha] = e.Emoticon;

                // create a session and send the invitation
                ObjectTransfer emoticonTransfer = nsMessageHandler.P2PHandler.RequestMsnObject(e.Sender, e.Emoticon);
                emoticonTransfer.TransferAborted  += (emoticonTransfer_TransferAborted);
                emoticonTransfer.TransferFinished += (emoticonTransfer_TransferFinished);

                MSNObjectCatalog.GetInstance().Add(e.Emoticon);

                if (EmoticonDefinitionReceived != null)
                {
                    EmoticonDefinitionReceived(this, e);
                }
            }
            else
            {
                if (EmoticonDefinitionReceived != null)
                {
                    EmoticonDefinitionReceived(this, e);
                }

                Emoticon existingEmoticon = existing as Emoticon;

                //If exists and data were ready, fire the event.
                if (existingEmoticon.DataReady)
                {
                    OnEmoticonReceived(this, new EmoticonArrivedEventArgs(e.Sender, existingEmoticon, null, e.RoutingInfo));
                }
                else
                {
                    Trace.WriteLineIf(Settings.TraceSwitch.TraceWarning,
                                      "An emoticon definition has been received, but the emoticon data were not yet completed.");
                }
            }
        }