Not logged in. · Lost password · Register
Forum: MatriX RSS
Page:  1  2  next
Avatar
bhavika4 #1
Member since Jul 2014 · 13 posts
Group memberships: Members
Show profile · Link to this post
Subject: Send message with Xamarin Android
I used MatriX.dll in xamarin Android and I'm trying to connect chat server and also send message. but I did not sent message...

  1. using System;
  2. using Android.App;
  3. using Android.Content;
  4. using Android.Runtime;
  5. using Android.Views;
  6. using Android.Widget;
  7. using Android.OS;
  8. using System.Threading;
  9. using Matrix;
  10. using Matrix.Xmpp;
  11. using Matrix.Xmpp.Client;
  12. using Matrix.Xmpp.Sasl;
  13. namespace AndroidChatAppXmpp
  14. {
  15.     [Activity(Label = "AndroidChatAppXmpp", MainLauncher = true, Icon = "@drawable/icon")]
  16.     public class MainActivity : Activity
  17.     {
  18.         XmppClient xmppClient = new XmppClient();
  19.         protected override void OnCreate(Bundle bundle)
  20.         {
  21.             base.OnCreate(bundle);
  22.             SetContentView(Resource.Layout.Main);
  23.             string lic = "jkdsfhkjdshg";
  24.             Matrix.License.LicenseManager.SetLicense(lic);
  25.             Button button = FindViewById<Button>(Resource.Id.MyButton);
  26.             button.Click += new EventHandler(button_Click);
  27.         }  
  28.         void button_Click(object sender, System.EventArgs e)
  29.         {
  30.             xmppClient.Username = "xyz@chat.servername.com";
  31.             xmppClient.Password = "xyz";
  32.             xmppClient.SetXmppDomain("chat.servername.com");
  33.             xmppClient.Port = 5222;
  34.             xmppClient.Status = "I was Online";
  35.             xmppClient.Show = Matrix.Xmpp.Show.chat;
  36.              
  37.  
  38.             try
  39.             {
  40.                 xmppClient.Open();
  41.                              
  42.             }
  43.             catch
  44.             {
  45.                 Console.WriteLine("Wrong login data!");
  46.             }
  47.  
  48.  
  49.             xmppClient.OnAuthError += new EventHandler<SaslEventArgs>(xmppClient_OnAuthError);
  50.             xmppClient.OnError += new EventHandler<ExceptionEventArgs>(xmppClient_OnError);
  51.             xmppClient.OnLogin += new EventHandler<Matrix.EventArgs>(xmppClient_OnLogin);
  52.             xmppClient.OnBeforeSasl += new EventHandler<SaslEventArgs>(xmppClient_OnBeforeSasl);
  53.  
  54.             xmppClient.OnReceiveXml += new EventHandler<TextEventArgs>(xmppClient_OnReceiveXml);
  55.             xmppClient.OnSendXml += new EventHandler<TextEventArgs>(xmppClient_OnSendXml);
  56.  
  57.             xmppClient.OnReceiveBody += new EventHandler<Matrix.Net.BodyEventArgs>(xmppClient_OnReceiveBody);
  58.             xmppClient.OnSendBody += new EventHandler<Matrix.Net.BodyEventArgs>(xmppClient_OnSendBody);
  59.  
  60.          
  61.  
  62.             xmppClient.OnMessage += new EventHandler<MessageEventArgs>(xmppClient_OnMessage);
  63.  
  64.         }
  65.  
  66.         void xmppClient_OnMessage(object sender, MessageEventArgs e)
  67.         {
  68.             if (e.Message.Body != null)
  69.             {
  70.                 Console.WriteLine(string.Format("OnMessage from {0}", e.Message.From));
  71.                 Console.WriteLine(string.Format("Body {0}", e.Message.Body));
  72.                 Console.WriteLine(string.Format("Type {0}", e.Message.Type));
  73.             }
  74.         }
  75.         void xmppClient_OnSendXml(object sender, TextEventArgs e)
  76.         {
  77.             Console.WriteLine("SEND: " + e.Text);
  78.         }
  79.  
  80.         void xmppClient_OnReceiveXml(object sender, TextEventArgs e)
  81.         {
  82.             Console.WriteLine("RECV: " + e.Text);
  83.         }
  84.  
  85.         void xmppClient_OnPresence(object sender, PresenceEventArgs e)
  86.         {
  87.             Console.WriteLine(string.Format("OnPresence from {0}", e.Presence.From));
  88.             Console.WriteLine(string.Format("Status {0}", e.Presence.Status));
  89.             Console.WriteLine(string.Format("Show type {0}", e.Presence.Show));
  90.             Console.WriteLine(string.Format("Priority {0}", e.Presence.Priority));
  91.         }
  92.     void xmppClient_OnBind(object sender, JidEventArgs e)
  93.         {
  94.             Console.WriteLine(e.Jid);
  95.  
  96.         }
  97.  
  98.         void xmppClient_OnBeforeSasl(object sender, SaslEventArgs e)
  99.         {
  100.             e.Auto = true;
  101.             e.SaslMechanism = Matrix.Xmpp.Sasl.SaslMechanism.PLAIN;
  102.         }
  103.         void xmppClient_OnLogin(object sender, Matrix.EventArgs e)
  104.        
  105.         {
  106.            
  107.  
  108.             var pm = new PresenceManager(xmppClient);
  109.             Jid jid = new Jid("abc@chat.servername.com");
  110.             pm.Subscribe(jid);
  111.  
  112.             xmppClient.OnPresence += new EventHandler<PresenceEventArgs>(xmppClient_OnPresence);
  113.            
  114.             var msg = new Matrix.Xmpp.Client.Message(jid, "Hello...!");
  115.  
  116.             xmppClient.Send(msg);
  117.          
  118.         }
  119.  
  120.         void xmppClient_OnError(object sender, ExceptionEventArgs e)
  121.         {
  122.             Console.WriteLine("Error: " + e.ToString());
  123.         }
  124.  
  125.         void xmppClient_OnAuthError(object sender, SaslEventArgs e)
  126.         {
  127.             Console.WriteLine("Error: " + e.ToString());
  128.         }
  129.         private void presenceManager_OnSubscribe(object sender, PresenceEventArgs e)
  130.         {
  131.             var pm = new PresenceManager(xmppClient);
  132.             pm.ApproveSubscriptionRequest(e.Presence.From);
  133.  
  134.         }
  135.         void xmppClient_OnSendBody(object sender, Matrix.Net.BodyEventArgs e)
  136.         {
  137.             Console.WriteLine("SEND: " + e.ToString());
  138.         }
  139.  
  140.         void xmppClient_OnReceiveBody(object sender, Matrix.Net.BodyEventArgs e)
  141.         {
  142.             Console.WriteLine("RECV: " + e.ToString());
  143.         }
  144.  
  145.     }
  146. }
I'm getting output...


  1. SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="chat.servarname.com" version="1.0" >
  2. SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="chat.servarname.com" version="1.0" >
  3. RECV: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="chat.servarname.com" id="9221d973" xml:lang="en" version="1.0" >
  4. RECV: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="chat.servarname.com" id="9221d973" xml:lang="en" version="1.0" >
  5. The request to load the assembly System.Core v2.0.5.0 was remapped to v3.5.0.0
  6. Unloading image System.Core.dll [0xc11698].
  7. Image addref System.Core[0xbbd708] -> System.Core.dll[0x29faa0]: 5
  8. Assembly Ref addref MatriX[0x1d8830] -> System.Core[0x2a05f8]: 4
  9. RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams">
  10. RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams">
  11.  <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls">
  12.     <required />
  13.  </starttls>
  14.  <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
  15.     <mechanism>DIGEST-MD5</mechanism>
  16.     <mechanism>PLAIN</mechanism>
  17.     <mechanism>ANONYMOUS</mechanism>
  18.     <mechanism>CRAM-MD5</mechanism>
  19.  </mechanisms>
  20. </stream:features>
  21. <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls">
  22. <required />
  23. </starttls>
  24. <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
  25. <mechanism>DIGEST-MD5</mechanism>
  26. <mechanism>PLAIN</mechanism>
  27. <mechanism>ANONYMOUS</mechanism>
  28. <mechanism>CRAM-MD5</mechanism>
  29. </mechanisms>
  30. </stream:features>
  31. SEND: <auth mechanism="DIGEST-MD5" xmlns="urn:ietf:params:xml:ns:xmpp-sasl" />
  32. SEND: <auth mechanism="DIGEST-MD5" xmlns="urn:ietf:params:xml:ns:xmpp-sasl" />
  33. RECV: <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cmVhbG09ImNoYXQuaXNlbmRvbmxpbmUuY29tIixub25jZT0iYW1XZHFSN2N1dEpXTmpYN0FBUjFzUzQ0ai9rdmdkU2o1RXg1S3J4SyIscW9wPSJhdXRoIixjaGFyc2V0PXV0Zi04LGFsZ29yaXRobT1tZDUtc2Vzcw==</challenge>
  34. RECV: <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cmVhbG09ImNoYXQuaXNlbmRvbmxpbmUuY29tIixub25jZT0iYW1XZHFSN2N1dEpXTmpYN0FBUjFzUzQ0ai9rdmdkU2o1RXg1S3J4SyIscW9wPSJhdXRoIixjaGFyc2V0PXV0Zi04LGFsZ29yaXRobT1tZDUtc2Vzcw==</challenge>
  35. SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9IndhbGxldGhvbGRlcjFAY2hhdC5pc2VuZG9ubGluZS5jb20iLHJlYWxtPSJjaGF0LmlzZW5kb25saW5lLmNvbSIsbm9uY2U9ImFtV2RxUjdjdXRKV05qWDdBQVIxc1M0NGova3ZnZFNqNUV4NUtyeEsiLGNub25jZT0iY2UxZTgzZDYwNWE0OWVjOTI5MjUzZTkzMDhmZTMyZjcwYTY1NDRhNmQyYjY1OTM3YTlmOWVhNTZjZDI5NGM1OCIsbmM9MDAwMDAwMDEscW9wPWF1dGgsZGlnZXN0LXVyaT0ieG1wcC9jaGF0LmlzZW5kb25saW5lLmNvbSIsY2hhcnNldD11dGYtOCxyZXNwb25zZT0zZTA2N2RjYzMxMjliYzQ0ZjNjYjMxY2MyM2JiODBmNw==</response>
  36. SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9IndhbGxldGhvbGRlcjFAY2hhdC5pc2VuZG9ubGluZS5jb20iLHJlYWxtPSJjaGF0LmlzZW5kb25saW5lLmNvbSIsbm9uY2U9ImFtV2RxUjdjdXRKV05qWDdBQVIxc1M0NGova3ZnZFNqNUV4NUtyeEsiLGNub25jZT0iY2UxZTgzZDYwNWE0OWVjOTI5MjUzZTkzMDhmZTMyZjcwYTY1NDRhNmQyYjY1OTM3YTlmOWVhNTZjZDI5NGM1OCIsbmM9MDAwMDAwMDEscW9wPWF1dGgsZGlnZXN0LXVyaT0ieG1wcC9jaGF0LmlzZW5kb25saW5lLmNvbSIsY2hhcnNldD11dGYtOCxyZXNwb25zZT0zZTA2N2RjYzMxMjliYzQ0ZjNjYjMxY2MyM2JiODBmNw==</response>
  37. RECV: <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cnNwYXV0aD00NDVhYTQ1YzMyYWNmZjFmMjNkZTg0NjM0YWI0Y2E1Zg==</success>
  38. RECV: <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cnNwYXV0aD00NDVhYTQ1YzMyYWNmZjFmMjNkZTg0NjM0YWI0Y2E1Zg==</success>
  39. SEND: <presence type="subscribe" to="abc@chat.servarname.com" id="MX_1" xmlns="jabber:client" />
  40. SEND: <presence type="subscribe" to="abc@chat.servarname.com" id="MX_1" xmlns="jabber:client" />
  41. SEND: <message to="abc@chat.servarname.com" xmlns="jabber:client">
  42. SEND: <message to="abc@chat.servarname.com" xmlns="jabber:client">
  43.  <body>Hello...!</body>
  44. </message>
  45. <body>Hello...!</body>
  46. </message>
  47. SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="chat.servarname.com" version="1.0" >
  48. SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="chat.servarname.com" version="1.0" >
  49. RECV: <stream:error xmlns:stream="http://etherx.jabber.org/streams" >
  50. RECV: <stream:error xmlns:stream="http://etherx.jabber.org/streams" >
  51. RECV: <not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-streams" />
  52. RECV: <not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-streams" />
  53. RECV: </stream:stream>
  54. RECV: </stream:stream>
  55. SEND: </stream:stream>
  56. SEND: </stream:stream>
This post was edited 2 times, last on 2014-07-31, 09:41 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
1) your xml output shows many lines twice, please check whats wrong there.
2) You are sending your message to early, please don't send your message before you get the 1st OnPresence event or the OnRosterEnd event.
3) Setup your event handlers before you call XmppClient.Open()

Alex
Avatar
bhavika4 #3
Member since Jul 2014 · 13 posts
Group memberships: Members
Show profile · Link to this post
did not call OnPresence event After login. Where I can send msg in which eventhandeler?

  1. using System;
  2. using Android.App;
  3. using Android.Content;
  4. using Android.Runtime;
  5. using Android.Views;
  6. using Android.Widget;
  7. using Android.OS;
  8. using System.Threading;
  9. using Matrix;
  10. using Matrix.Xmpp;
  11. using Matrix.Xmpp.Client;
  12. using Matrix.Xmpp.Sasl;
  13.  
  14. namespace AndroidChatAppXmpp
  15. {
  16.     [Activity(Label = "AndroidChatAppXmpp", MainLauncher = true, Icon = "@drawable/icon")]
  17.     public class MainActivity : Activity
  18.     {
  19.         XmppClient xmppClient = new XmppClient();
  20.  
  21.  
  22.      
  23.         protected override void OnCreate(Bundle bundle)
  24.         {
  25.             base.OnCreate(bundle);
  26.  
  27.             SetContentView(Resource.Layout.Main);
  28.  
  29.             string lic = @"...";
  30.  
  31.             Matrix.License.LicenseManager.SetLicense(lic);
  32.  
  33.             Button button = FindViewById<Button>(Resource.Id.MyButton);
  34.  
  35.             button.Click += new EventHandler(button_Click);
  36.         }
  37.         void button_Click(object sender, System.EventArgs e)
  38.         {
  39.         xmppClient.Username = "xyz@chat.servername.com";
  40.             xmppClient.Password = "xyz";
  41.             xmppClient.SetXmppDomain("chat.servername.com");
  42.             xmppClient.Port = 5222;
  43.             xmppClient.Status = "I was Online";
  44.             xmppClient.Show = Matrix.Xmpp.Show.chat;
  45.  
  46.             xmppClient.OnAuthError += new EventHandler<SaslEventArgs>(xmppClient_OnAuthError);
  47.             xmppClient.OnError += new EventHandler<ExceptionEventArgs>(xmppClient_OnError);
  48.             xmppClient.OnLogin += new EventHandler<Matrix.EventArgs>(xmppClient_OnLogin);
  49.             xmppClient.OnBeforeSasl += new EventHandler<SaslEventArgs>(xmppClient_OnBeforeSasl);
  50.  
  51.             xmppClient.OnReceiveXml += new EventHandler<TextEventArgs>(xmppClient_OnReceiveXml);
  52.             xmppClient.OnSendXml += new EventHandler<TextEventArgs>(xmppClient_OnSendXml);
  53.  
  54.             xmppClient.OnReceiveBody += new EventHandler<Matrix.Net.BodyEventArgs>(xmppClient_OnReceiveBody);
  55.             xmppClient.OnSendBody += new EventHandler<Matrix.Net.BodyEventArgs>(xmppClient_OnSendBody);
  56.         xmppClient.OnMessage += new EventHandler<MessageEventArgs>(xmppClient_OnMessage);
  57.  
  58.  
  59.             try
  60.             {
  61.                 xmppClient.Open();
  62.                 // xmpp.OnLogin += new EventHandler<Matrix.EventArgs>(xmpp_OnLogin);               
  63.             }
  64.             catch
  65.             {
  66.                 Console.WriteLine("Wrong login data!");
  67.             }
  68.             Thread.Sleep(500);
  69.             xmppClient.OnPresence += new EventHandler<PresenceEventArgs>(xmppClient_OnPresence);
  70.             xmppClient.AutoRoster = true;
  71.         }
  72.         void xmppClient_OnMessage(object sender, MessageEventArgs e)
  73.         {
  74.             if (e.Message.Body != null)
  75.             {
  76.                 Console.WriteLine(string.Format("OnMessage from {0}", e.Message.From));
  77.                 Console.WriteLine(string.Format("Body {0}", e.Message.Body));
  78.                 Console.WriteLine(string.Format("Type {0}", e.Message.Type));
  79.             }
  80.         }
  81.         void xmppClient_OnSendXml(object sender, TextEventArgs e)
  82.         {
  83.             Console.WriteLine("SEND: " + e.Text);
  84.         }
  85.         void xmppClient_OnReceiveXml(object sender, TextEventArgs e)
  86.         {
  87.             Console.WriteLine("RECV: " + e.Text);
  88.         }
  89.         void xmppClient_OnPresence(object sender, PresenceEventArgs e)
  90.         {
  91.             Console.WriteLine(string.Format("OnPresence from {0}", e.Presence.From));
  92.             Console.WriteLine(string.Format("Status {0}", e.Presence.Status));
  93.             Console.WriteLine(string.Format("Show type {0}", e.Presence.Show));
  94.             Console.WriteLine(string.Format("Priority {0}", e.Presence.Priority));
  95.  
  96.  
  97.             //var pm = new PresenceManager(xmppClient);
  98.             //Jid jid = new Jid("abc@chat.servername.com");
  99.             //pm.Subscribe(jid);
  100.             //var msg = new Matrix.Xmpp.Client.Message(jid, "Hello...!");
  101.  
  102.             //xmppClient.Send(msg);
  103.         }
  104.  
  105.         void xmppClient_OnBeforeSasl(object sender, SaslEventArgs e)
  106.         {
  107.             e.Auto = true;
  108.             e.SaslMechanism = Matrix.Xmpp.Sasl.SaslMechanism.PLAIN;
  109.         }
  110.         void xmppClient_OnLogin(object sender, Matrix.EventArgs e)
  111.         {
  112.             Console.WriteLine("Message: logged in successfully ");
  113.         }
  114.  
  115.         void xmppClient_OnError(object sender, ExceptionEventArgs e)
  116.         {
  117.             Console.WriteLine("Error: " + e.ToString());
  118.         }
  119.  
  120.         void xmppClient_OnAuthError(object sender, SaslEventArgs e)
  121.         {
  122.             Console.WriteLine("Error: " + e.ToString());
  123.         }
  124.         private void presenceManager_OnSubscribe(object sender, PresenceEventArgs e)
  125.         {
  126.             var pm = new PresenceManager(xmppClient);
  127.             pm.ApproveSubscriptionRequest(e.Presence.From);
  128.  
  129.         }
  130.         void xmppClient_OnSendBody(object sender, Matrix.Net.BodyEventArgs e)
  131.         {
  132.             Console.WriteLine("SEND: " + e.ToString());
  133.         }
  134.  
  135.         void xmppClient_OnReceiveBody(object sender, Matrix.Net.BodyEventArgs e)
  136.         {
  137.             Console.WriteLine("RECV: " + e.ToString());
  138.         }
  139.  
  140.     }
  141. }
This post was edited on 2014-07-31, 12:15 by Alex.
Avatar
Alex #4
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
  • please post your XML logs. Without them I cannot help
  • Remove the Sleep after the Open call. Makes no sense.
  • The Open call does not throw an Exception. YOu don't need try catch here. When login data is wrong you get an AuthError event
  • Username normalley is "xyz" only, nor "xyz@chat.servername.com"
Avatar
bhavika4 #5
Member since Jul 2014 · 13 posts
Group memberships: Members
Show profile · Link to this post
I tired your Example.ZIP but it's not working and I could not find output which shows many lines twice.I also post my code and XML logs.did not call OnPresence event After login. Where I can send msg in which eventhandeler?
  1. using System;
  2. using Android.App;
  3. using Android.Content;
  4. using Android.Runtime;
  5. using Android.Views;
  6. using Android.Widget;
  7. using Android.OS;
  8. using System.Threading;
  9. using Matrix;
  10. using Matrix.Xmpp;
  11. using Matrix.Xmpp.Client;
  12. using Matrix.Xmpp.Sasl;
  13.  
  14. namespace AndroidChatAppXmpp
  15. {
  16.     [Activity(Label = "AndroidChatAppXmpp", MainLauncher = true, Icon = "@drawable/icon")]
  17.     public class MainActivity : Activity
  18.     {
  19.         XmppClient xmppClient = new XmppClient();
  20.         protected override void OnCreate(Bundle bundle)
  21.         {
  22.             base.OnCreate(bundle);
  23.  
  24.             SetContentView(Resource.Layout.Main);
  25.  
  26.             string lic = @"...";
  27.  
  28.             Matrix.License.LicenseManager.SetLicense(lic);
  29.  
  30.             Button button = FindViewById<Button>(Resource.Id.MyButton);
  31.  
  32.             button.Click += new EventHandler(button_Click);
  33.         }
  34.    
  35.         void button_Click(object sender, System.EventArgs e)
  36.         {
  37.            
  38.             xmppClient.Username = "Xyz";
  39.             xmppClient.Password = "hfjhdjg";
  40.             xmppClient.SetXmppDomain("chat.servername.com");
  41.             xmppClient.Port = 5222;
  42.             xmppClient.Status = "I am Online";
  43.             xmppClient.Show = Matrix.Xmpp.Show.chat;
  44.          
  45.             xmppClient.OnAuthError += new EventHandler<SaslEventArgs>(xmppClient_OnAuthError);
  46.             xmppClient.OnError += new EventHandler<ExceptionEventArgs>(xmppClient_OnError);
  47.             xmppClient.OnLogin += new EventHandler<Matrix.EventArgs>(xmppClient_OnLogin);
  48.             xmppClient.OnBeforeSasl += new EventHandler<SaslEventArgs>(xmppClient_OnBeforeSasl);
  49.  
  50.             xmppClient.OnReceiveXml += new EventHandler<TextEventArgs>(xmppClient_OnReceiveXml);
  51.             xmppClient.OnSendXml += new EventHandler<TextEventArgs>(xmppClient_OnSendXml);
  52.  
  53.             xmppClient.OnReceiveBody += new EventHandler<Matrix.Net.BodyEventArgs>(xmppClient_OnReceiveBody);
  54.             xmppClient.OnSendBody += new EventHandler<Matrix.Net.BodyEventArgs>(xmppClient_OnSendBody);
  55.  
  56.             xmppClient.OnPresence += new EventHandler<PresenceEventArgs>(xmppClient_OnPresence);
  57.             xmppClient.AutoRoster = true;
  58.      
  59.  
  60.             xmppClient.Open();
  61.  
  62.         }
  63.         void xmppClient_OnBind(object sender, JidEventArgs e)
  64.         {
  65.             Console.WriteLine(e.Jid);
  66.         }
  67.         void xmppClient_OnBeforeSasl(object sender, SaslEventArgs e)
  68.         {
  69.             e.Auto = true;
  70.             e.SaslMechanism = Matrix.Xmpp.Sasl.SaslMechanism.PLAIN;
  71.         }
  72.         void xmppClient_OnLogin(object sender, Matrix.EventArgs e)
  73.         {
  74.             Console.WriteLine("Message: logged in successfully ");
  75.         }
  76.  
  77.         void xmppClient_OnError(object sender, ExceptionEventArgs e)
  78.         {
  79.             Console.WriteLine("Error: " + e.ToString());
  80.         }
  81.  
  82.         void xmppClient_OnAuthError(object sender, SaslEventArgs e)
  83.         {
  84.             Console.WriteLine("Error: " + e.ToString());
  85.         }
  86.         private void presenceManager_OnSubscribe(object sender, PresenceEventArgs e)
  87.         {
  88.             var pm = new PresenceManager(xmppClient);
  89.             pm.ApproveSubscriptionRequest(e.Presence.From);
  90.  
  91.         }
  92.         void xmppClient_OnSendBody(object sender, Matrix.Net.BodyEventArgs e)
  93.         {
  94.             Console.WriteLine("SENDBody: " + e.ToString());
  95.         }
  96.  
  97.         void xmppClient_OnReceiveBody(object sender, Matrix.Net.BodyEventArgs e)
  98.         {
  99.             Console.WriteLine("RECVBody: " + e.ToString());
  100.         }
  101.         void xmppClient_OnMessage(object sender, MessageEventArgs e)
  102.         {
  103.             if (e.Message.Body != null)
  104.             {
  105.                 Console.WriteLine(string.Format("OnMessage from {0}", e.Message.From));
  106.                 Console.WriteLine(string.Format("Body {0}", e.Message.Body));
  107.                 Console.WriteLine(string.Format("Type {0}", e.Message.Type));
  108.             }
  109.         }
  110.         void xmppClient_OnSendXml(object sender, TextEventArgs e)
  111.         {
  112.             Console.WriteLine("SEND: " + e.Text);
  113.         }
  114.         void xmppClient_OnReceiveXml(object sender, TextEventArgs e)
  115.         {
  116.             Console.WriteLine("RECV: " + e.Text);
  117.         }
  118.         void xmppClient_OnPresence(object sender, PresenceEventArgs e)
  119.         {
  120.             Console.WriteLine(string.Format("OnPresence from {0}", e.Presence.From));
  121.             Console.WriteLine(string.Format("Status {0}", e.Presence.Status));
  122.             Console.WriteLine(string.Format("Show type {0}", e.Presence.Show));
  123.             Console.WriteLine(string.Format("Priority {0}", e.Presence.Priority));
  124.         }
  125.  
  126.     }
  127. }

  1. SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="chat.servername.com" version="1.0" >
  2. SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="chat.servername.com" version="1.0" >
  3. RECV: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="chat.servername.com" id="f89746fc" xml:lang="en" version="1.0" >
  4. RECV: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="chat.servername.com" id="f89746fc" xml:lang="en" version="1.0" >
  5. The request to load the assembly System.Core v2.0.5.0 was remapped to v3.5.0.0 Unloading image System.Core.dll [0xbcb570].
  6. Image addref System.Core[0xbcb570] -> System.Core.dll[0x29e390]: 5
  7. Assembly Ref addref MatriX[0x15b888] -> System.Core[0x29eee8]: 4
  8. RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams">
  9. RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams">
  10.  <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls">
  11. <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls">
  12.     <required />
  13. <required />
  14.  </starttls>
  15. </starttls>
  16.  <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
  17. <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
  18.     <mechanism>DIGEST-MD5</mechanism>
  19.     <mechanism>PLAIN</mechanism>
  20. <mechanism>DIGEST-MD5</mechanism>
  21. <mechanism>PLAIN</mechanism>
  22. <mechanism>ANONYMOUS</mechanism>
  23.     <mechanism>ANONYMOUS</mechanism>
  24.     <mechanism>CRAM-MD5</mechanism>
  25.  </mechanisms>
  26. </stream:features>
  27. <mechanism>CRAM-MD5</mechanism>
  28. </mechanisms>
  29. </stream:features>
  30. SEND: <auth mechanism="DIGEST-MD5" xmlns="urn:ietf:params:xml:ns:xmpp-sasl" />
  31. SEND: <auth mechanism="DIGEST-MD5" xmlns="urn:ietf:params:xml:ns:xmpp-sasl" />
  32. RECV: <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cmVhbG09ImNoYXQuaXNlbmRvbmxpbmUuY29tIixub25jZT0iRXpjTkhiWVg4ZzRNN3MvMyt5VjZtdVg5UHVvSWNBSE9tSWpMNUpQaiIscW9wPSJhdXRoIixjaGFyc2V0PXV0Zi04LGFsZ29yaXRobT1tZDUtc2Vzcw==</challenge>
  33. RECV: <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cmVhbG09ImNoYXQuaXNlbmRvbmxpbmUuY29tIixub25jZT0iRXpjTkhiWVg4ZzRNN3MvMyt5VjZtdVg5UHVvSWNBSE9tSWpMNUpQaiIscW9wPSJhdXRoIixjaGFyc2V0PXV0Zi04LGFsZ29yaXRobT1tZDUtc2Vzcw==</challenge>
  34. SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9IndhbGxldGhvbGRlcjEiLHJlYWxtPSJjaGF0LmlzZW5kb25saW5lLmNvbSIsbm9uY2U9IkV6Y05IYllYOGc0TTdzLzMreVY2bXVYOVB1b0ljQUhPbUlqTDVKUGoiLGNub25jZT0iY2QxNDE1ZmFhMjY4MTFjZTEyMmJlZDM2OTA4NmFiOWU3ZDRhZjE3ZDc2NGE4YWQ3NjY4MzRmZjViZjNmOThjMyIsbmM9MDAwMDAwMDEscW9wPWF1dGgsZGlnZXN0LXVyaT0ieG1wcC9jaGF0LmlzZW5kb25saW5lLmNvbSIsY2hhcnNldD11dGYtOCxyZXNwb25zZT0wZWExODVhMWYyYmE5ZjEwMGQwZDJmZmFiY2YwOTdiMQ==</response>
  35. SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9IndhbGxldGhvbGRlcjEiLHJlYWxtPSJjaGF0LmlzZW5kb25saW5lLmNvbSIsbm9uY2U9IkV6Y05IYllYOGc0TTdzLzMreVY2bXVYOVB1b0ljQUhPbUlqTDVKUGoiLGNub25jZT0iY2QxNDE1ZmFhMjY4MTFjZTEyMmJlZDM2OTA4NmFiOWU3ZDRhZjE3ZDc2NGE4YWQ3NjY4MzRmZjViZjNmOThjMyIsbmM9MDAwMDAwMDEscW9wPWF1dGgsZGlnZXN0LXVyaT0ieG1wcC9jaGF0LmlzZW5kb25saW5lLmNvbSIsY2hhcnNldD11dGYtOCxyZXNwb25zZT0wZWExODVhMWYyYmE5ZjEwMGQwZDJmZmFiY2YwOTdiMQ==</response>
  36. RECV: <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cnNwYXV0aD0wM2Y3NGEzZWVjMmIxZGIxYzM3ZDViNjRmYjk4ODg4NQ==</success>
  37. RECV: <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cnNwYXV0aD0wM2Y3NGEzZWVjMmIxZGIxYzM3ZDViNjRmYjk4ODg4NQ==</success>
  38. Message: logged in successfully
  39. Message: logged in successfully
  40. SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="chat.servername.com" version="1.0" >
  41. SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="chat.servername.com" version="1.0" >
  42. RECV: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="chat.servername.com" id="f89746fc" xml:lang="en" version="1.0" >
  43. RECV: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="chat.servername.com" id="f89746fc" xml:lang="en" version="1.0" >
  44. RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams" />
  45. RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams" />
This post was edited 2 times, last on 2014-07-31, 12:52 by Alex.
Avatar
Alex #6
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I think there is a problem with Tls.
Can you please check of xmppClient.StartTls is set to true? Your server requires a secure connection with StartTls.
Avatar
bhavika4 #7
Member since Jul 2014 · 13 posts
Group memberships: Members
Show profile · Link to this post
How to set StartTLS= true in Matrix? Jabber-net is provided to set this property.
Avatar
Alex #8
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I posted the code above.

  1. xmppClient.StartTls = true;
Avatar
bhavika4 #9
Member since Jul 2014 · 13 posts
Group memberships: Members
Show profile · Link to this post
This property is only get property in Matrix. Please check attachment.
The author has attached one file to this post:
Image.png 223.5 kBytes
You have no permission to open this file.
This post was edited on 2014-07-31, 13:16 by bhavika4.
Avatar
Alex #10
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Please use the attached build 1.5.5.9.
TLS should be enabled by default there, and you can set it.
This post was edited on 2014-07-31, 15:11 by Alex.
Avatar
bhavika4 #11
Member since Jul 2014 · 13 posts
Group memberships: Members
Show profile · Link to this post
Thanks...!

But you did not tell me when and where I can send message?
Avatar
Alex #12
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
You can send it anytime after you got the OnRosterEnd event. Or better the first incoming OnPresence event.
Before these events your session is not ready for sending out Iqs or Messages.

Please let me know if its working with this build.

Alex
Avatar
bhavika4 #13
Member since Jul 2014 · 13 posts
Group memberships: Members
Show profile · Link to this post
I got error in OnError "ClientSocket Connection request failed."
This post was edited on 2014-07-31, 13:59 by bhavika4.
Avatar
Alex #14
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
sorry, there was a small TLS problem.
Please use the latest attached build. This is working fine for me.

I also checked the Android sample and its running without any problems for me.
Have you set your demo license there?

Alex
The author has attached one file to this post:
MatriX_Android.zip 300.5 kBytes
You have no permission to open this file.
Avatar
bhavika4 #15
Member since Jul 2014 · 13 posts
Group memberships: Members
Show profile · Link to this post
I tried your Matrix.dll but I got same error again "client socket is failed".

code is working in .Net Console Application. but it's not working in Xamarin Android so Can you give me your android code?
This post was edited on 2014-07-31, 15:33 by bhavika4.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Page:  1  2  next
Forum: MatriX RSS