Not logged in. · Lost password · Register
Forum: MatriX RSS
Page: previous  1  2 
Avatar
Alex #16
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post ID 8666
I told you where you can find an Android example. And this example is working fine for me when I use the MatriX Android build which I have attached here in the thread.
Avatar
Alex #17
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Is the hostname of your server the same as the XMPP Domain?
if not then you have to set the Hostname property also on Android. because SRV lookups are not implemented in the Android version.
Alex
Avatar
bhavika4 #18
Member since Jul 2014 · 13 posts
Group memberships: Members
Show profile · Link to this post
Please Check My code..! host name and domain name both are different.I'm getting error Could not resolve host 'isendonline.com' 
Exception:- System.Net.Sockets.SocketException.

  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 = "bhavika1@chat.isendonline.com";
  39.         // xmppClient.Username = "bhavika1";
  40.  
  41.             xmppClient.Password = "*****";
  42.             xmppClient.XmppDomain = "chat.isendonline.com";
  43.             xmppClient.Hostname = "isendonline.com";
  44.             xmppClient.Port = 5222;
  45.             xmppClient.Status = "I am Online";
  46.             xmppClient.Show = Matrix.Xmpp.Show.chat;
  47.             xmppClient.StartTls = true;
  48.  
  49.            
  50.          
  51.             xmppClient.OnAuthError += new EventHandler<SaslEventArgs>(xmppClient_OnAuthError);
  52.             xmppClient.OnError += new EventHandler<ExceptionEventArgs>(xmppClient_OnError);
  53.             xmppClient.OnLogin += new EventHandler<Matrix.EventArgs>(xmppClient_OnLogin);
  54.             xmppClient.OnBeforeSasl += new EventHandler<SaslEventArgs>(xmppClient_OnBeforeSasl);
  55.  
  56.             xmppClient.OnReceiveXml += new EventHandler<TextEventArgs>(xmppClient_OnReceiveXml);
  57.             xmppClient.OnSendXml += new EventHandler<TextEventArgs>(xmppClient_OnSendXml);
  58.  
  59.             xmppClient.OnReceiveBody += new EventHandler<Matrix.Net.BodyEventArgs>(xmppClient_OnReceiveBody);
  60.             xmppClient.OnSendBody += new EventHandler<Matrix.Net.BodyEventArgs>(xmppClient_OnSendBody);
  61.  
  62.             xmppClient.OnPresence += new EventHandler<PresenceEventArgs>(xmppClient_OnPresence);
  63.             xmppClient.AutoRoster = true;
  64.      
  65.  
  66.             xmppClient.Open();
  67.  
  68.         }
  69.         void xmppClient_OnBind(object sender, JidEventArgs e)
  70.         {
  71.             Console.WriteLine(e.Jid);
  72.         }
  73.         void xmppClient_OnBeforeSasl(object sender, SaslEventArgs e)
  74.         {
  75.             e.Auto = true;
  76.             e.SaslMechanism = Matrix.Xmpp.Sasl.SaslMechanism.PLAIN;
  77.         }
  78.         void xmppClient_OnLogin(object sender, Matrix.EventArgs e)
  79.         {
  80.            // Console.WriteLine("Message: logged in successfully ");
  81.             var pm = new PresenceManager(xmppClient);
  82.             Jid jid = new Jid("Divya@chat.isendonline.com");
  83.             pm.Subscribe(jid);
  84.  
  85.             var msg = new Matrix.Xmpp.Client.Message(jid, "Hello...!");
  86.  
  87.             xmppClient.Send(msg);
  88.         }
  89.  
  90.         void xmppClient_OnError(object sender, ExceptionEventArgs e)
  91.         {
  92.             Console.WriteLine("Error: " + e.ToString());
  93.         }
  94.  
  95.         void xmppClient_OnAuthError(object sender, SaslEventArgs e)
  96.         {
  97.             Console.WriteLine("Error: " + e.ToString());
  98.         }
  99.         private void presenceManager_OnSubscribe(object sender, PresenceEventArgs e)
  100.         {
  101.             var pm = new PresenceManager(xmppClient);
  102.             pm.ApproveSubscriptionRequest(e.Presence.From);
  103.  
  104.         }
  105.         void xmppClient_OnSendBody(object sender, Matrix.Net.BodyEventArgs e)
  106.         {
  107.             Console.WriteLine("SENDBody: " + e.ToString());
  108.         }
  109.  
  110.         void xmppClient_OnReceiveBody(object sender, Matrix.Net.BodyEventArgs e)
  111.         {
  112.             Console.WriteLine("RECVBody: " + e.ToString());
  113.         }
  114.         void xmppClient_OnMessage(object sender, MessageEventArgs e)
  115.         {
  116.             if (e.Message.Body != null)
  117.             {
  118.                 Console.WriteLine(string.Format("OnMessage from {0}", e.Message.From));
  119.                 Console.WriteLine(string.Format("Body {0}", e.Message.Body));
  120.                 Console.WriteLine(string.Format("Type {0}", e.Message.Type));
  121.             }
  122.         }
  123.         void xmppClient_OnSendXml(object sender, TextEventArgs e)
  124.         {
  125.             Console.WriteLine("SEND: " + e.Text);
  126.         }
  127.         void xmppClient_OnReceiveXml(object sender, TextEventArgs e)
  128.         {
  129.             Console.WriteLine("RECV: " + e.Text);
  130.         }
  131.         void xmppClient_OnPresence(object sender, PresenceEventArgs e)
  132.         {
  133.             Console.WriteLine(string.Format("OnPresence from {0}", e.Presence.From));
  134.             Console.WriteLine(string.Format("Status {0}", e.Presence.Status));
  135.             Console.WriteLine(string.Format("Show type {0}", e.Presence.Show));
  136.             Console.WriteLine(string.Format("Priority {0}", e.Presence.Priority));
  137.         }
  138.  
  139.     }
  140. }
This post was edited on 2014-07-31, 17:02 by Alex.
Avatar
Alex #19
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
  • has you emulator or device working internet?
  • can you emulator or device resolve the IP for isendonline.com?
  • have you tried with an IP address instead of isendonline.com as hostname?

It was able to connect before in the logs you sent. So I see no reason why it fails now.
I am not able to connect to isendonline.com, I think this server is not on the internet. So I can't test your server and help.
Avatar
bhavika4 #20
Member since Jul 2014 · 13 posts
Group memberships: Members
Show profile · Link to this post
Hello Sir..!
First Thanks for helping me and also quick reply me.

I used IP ADDRESS of chat.isendonline.com. It's working.
Avatar
Alex #21
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
great to hear. So its working on Desktop and on Android now?
Avatar
bhavika4 #22
Member since Jul 2014 · 13 posts
Group memberships: Members
Show profile · Link to this post
Already it worked in desktop but Now it's also working Xamarin Android
Avatar
Alex #23
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
great to hear
Avatar
bhavika4 #24
Member since Jul 2014 · 13 posts
Group memberships: Members
Show profile · Link to this post
How to get Receive message in which method? I got receive message in XML Log.
Avatar
Alex #25
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post ID 8666
OnMessage handler.

For new topics please open new threads.
And please study the MiniClient example which comes with the full download of the desktop version. There is everything included you need.

Alex
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: previous  1  2 
Forum: MatriX RSS