Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Net.Security;
- using System.Security.Cryptography.X509Certificates;
- using agsXMPP;
- using agsXMPP.protocol.client;
- namespace XMPPTest
- {
- class Program
- {
- private static XmppClientConnection conn;
- static void Main(string[] args)
- {
- conn = new XmppClientConnection("jabber.cz");
- conn.UseStartTLS = true;
- conn.Username = "user";
- conn.Password = "password";
- conn.Resource = "test";
- conn.Priority = 5;
- conn.OnAuthError += new XmppElementHandler(conn_OnAuthError);
- conn.OnLogin += new ObjectHandler(conn_OnLogin);
- conn.OnError += new ErrorHandler(conn_OnError);
- conn.ClientSocket.OnValidateCertificate += new RemoteCertificateValidationCallback(ClientSocket_OnValidateCertificate);
- conn.Open();
- bool term = false;
- while (!term)
- {
- char c = (char)Console.Read();
- switch (c)
- {
- case 'q':
- case 'Q':
- term = true;
- break;
- case 'm':
- case 'M':
- conn.Send(new Message("anotheruser@jabbim.cz", "hello"));
- break;
- }
- }
- conn.Close();
- }
- static void conn_OnAuthError(object sender, agsXMPP.Xml.Dom.Element e)
- {
- Console.WriteLine("OnAuthError()");
- }
- static bool ClientSocket_OnValidateCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
- {
- X509Certificate2 cert2 = certificate as X509Certificate2;
- if (cert2 != null)
- {
- bool valid = cert2.Verify();
- return valid;
- }
- else
- return false;
- }
- static void conn_OnError(object sender, Exception ex)
- {
- Console.WriteLine(ex.ToString());
- }
- static void conn_OnLogin(object sender)
- {
- Console.WriteLine("OnLogin()");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement