コード例 #1
0
ファイル: Shell.cs プロジェクト: kwerty/Messenger-Library
        async void Msgr_InvitedToIMSession(object sender, InvitationEventArgs e)
        {

            using (ConsoleExt.WithColor(eventColor))
                Console.WriteLine("Accepting IM Session invitation from {0}", e.Invitation.InvitingUser.Nickname ?? e.Invitation.InvitingUser.LoginName);

            IMSession imSession = null;

            try
            {
                imSession = await Msgr.AcceptInvitationAsync(e.Invitation);
            }
            catch (ConnectionErrorException ex)
            {
                using (ConsoleExt.WithColor(errorColor))
                    Console.WriteLine("Connection error while esablishing IM session: " + ex.Message);

                return;
            }

            Message message = new Message();

            MessageFormatter mf = new MessageFormatter();
            mf.Italic = true;
            mf.Color = Color.Tomato;
            mf.ApplyFormat(message);

            message.Body = UTF8Encoding.UTF8.GetBytes(String.Format("Gee, thanks for inviting me {0}", e.Invitation.InvitingUser.Nickname ?? e.Invitation.InvitingUser.LoginName));

            await imSession.SendMessageAsync(message);
        }
コード例 #2
0
 void OnInvitedToIMSession(InvitationEventArgs e)
 {
     EventHandler<InvitationEventArgs> handler = InvitedToIMSession;
     if (handler != null) handler(this, e);
 }