Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Page:  1  2  next
Avatar
ramraaj #1
Member since Dec 2009 · 4 posts
Group memberships: Members
Show profile · Link to this post
Subject: Windows mobile 6 + Net3.5 + Google talk
Hello Alex and any other who could help   :-/  ,
I have tried this .. i don't know how many times.. but never successful.

I am trying to accomplish, at least once , a successful connection to google talk servers and download my friends list. Just this. It doesnt work at all . I tried all the desktop clients , console clients .. and they work beautifully .

First I tried to implement the MiniclientWM5 as is to my phone .. but as soon as I login .. it doesn't do anything. it stays offline .
Second I made my own little program ..just to see if I can just connect and download my friends list but that also doesnt work and after logging in xmpp.Close() is called. Its like it doesnt fire any event as soon as it is logged in.

My code is

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using agsXMPP;


namespace SmartDeviceProject5
{
    public partial class Form1 : Form
    {
        XmppClientConnection xmppCon = new XmppClientConnection();
        public Form1()
        {
            InitializeComponent();
            Init();
        }

        private void Init()
        {
            listEvents.Items.Clear();

            // Subscribe to Events
            xmppCon.OnLogin += new ObjectHandler(xmppCon_OnLogin);
            xmppCon.OnRosterStart += new ObjectHandler(xmppCon_OnRosterStart);
            xmppCon.OnRosterEnd += new ObjectHandler(xmppCon_OnRosterEnd);
            xmppCon.OnRosterItem += new XmppClientConnection.RosterHandler(xmppCon_OnRosterItem);
            xmppCon.OnPresence += new agsXMPP.protocol.client.PresenceHandler(xmppCon_OnPresence);
            xmppCon.OnAuthError += new XmppElementHandler(xmppCon_OnAuthError);
            xmppCon.OnError += new ErrorHandler(xmppCon_OnError);
            xmppCon.OnClose += new ObjectHandler(xmppCon_OnClose);
            xmppCon.OnMessage += new agsXMPP.protocol.client.MessageHandler(xmppCon_OnMessage);
        }

        void xmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
        {
            // ignore empty messages (events)
            if (msg.Body == null)
                return;

            if (InvokeRequired)
            {
                // Windows Forms are not Thread Safe, we need to invoke this :(
                // We're not in the UI thread, so we need to call BeginInvoke               
                BeginInvoke(new agsXMPP.protocol.client.MessageHandler(xmppCon_OnMessage), new object[] { sender, msg });
                return;
            }

            listEvents.Items.Add(String.Format("OnMessage from:{0} type:{1}", msg.From.Bare, msg.Type.ToString()));
            listEvents.Items.Add(msg.Body);
            listEvents.SelectedIndex = listEvents.Items.Count - 1;
        }

        void xmppCon_OnClose(object sender)
        {
            if (InvokeRequired)
            {
                // Windows Forms are not Thread Safe, we need to invoke this :(
                // We're not in the UI thread, so we need to call BeginInvoke               
                BeginInvoke(new ObjectHandler(xmppCon_OnClose), new object[] { sender });
                return;
            }
            listEvents.Items.Add("OnClose Connection closed");
            listEvents.SelectedIndex = listEvents.Items.Count - 1;
        }

        void xmppCon_OnError(object sender, Exception ex)
        {
            if (InvokeRequired)
            {
                // Windows Forms are not Thread Safe, we need to invoke this :(
                // We're not in the UI thread, so we need to call BeginInvoke               
                BeginInvoke(new ErrorHandler(xmppCon_OnError), new object[] { sender, ex });
                return;
            }
            listEvents.Items.Add("OnError");
            listEvents.SelectedIndex = listEvents.Items.Count - 1;
        }

        void xmppCon_OnAuthError(object sender, agsXMPP.Xml.Dom.Element e)
        {
            if (InvokeRequired)
            {
                // Windows Forms are not Thread Safe, we need to invoke this :(
                // We're not in the UI thread, so we need to call BeginInvoke               
                BeginInvoke(new XmppElementHandler(xmppCon_OnAuthError), new object[] { sender, e });
                return;
            }
            listEvents.Items.Add("OnAuthError");
            listEvents.SelectedIndex = listEvents.Items.Count - 1;
        }

        void xmppCon_OnPresence(object sender, agsXMPP.protocol.client.Presence pres)
        {
            if (InvokeRequired)
            {
                // Windows Forms are not Thread Safe, we need to invoke this :(
                // We're not in the UI thread, so we need to call BeginInvoke               
                BeginInvoke(new agsXMPP.protocol.client.PresenceHandler(xmppCon_OnPresence), new object[] { sender, pres });
                return;
            }
            listEvents.Items.Add(String.Format("Received Presence from:{0} show:{1} status:{2}", pres.From.ToString(), pres.Show.ToString(), pres.Status));
            listEvents.SelectedIndex = listEvents.Items.Count - 1;
        }

        void xmppCon_OnRosterItem(object sender, agsXMPP.protocol.iq.roster.RosterItem item)
        {
            if (InvokeRequired)
            {
                // Windows Forms are not Thread Safe, we need to invoke this :(
                // We're not in the UI thread, so we need to call BeginInvoke               
                BeginInvoke(new XmppClientConnection.RosterHandler(xmppCon_OnRosterItem), new object[] { sender, item });
                return;
            }
            listEvents.Items.Add(String.Format("Received Contact {0}", item.Jid.Bare));
            listEvents.SelectedIndex = listEvents.Items.Count - 1;
        }

        void xmppCon_OnRosterEnd(object sender)
        {
            if (InvokeRequired)
            {
                // Windows Forms are not Thread Safe, we need to invoke this :(
                // We're not in the UI thread, so we need to call BeginInvoke               
                BeginInvoke(new ObjectHandler(xmppCon_OnRosterEnd), new object[] { sender });
                return;
            }
            listEvents.Items.Add("OnRosterEnd");
            listEvents.SelectedIndex = listEvents.Items.Count - 1;

            // Send our own presence to teh server, so other epople send us online
            // and the server sends us the presences of our contacts when they are
            // available
            xmppCon.SendMyPresence();
        }

        void xmppCon_OnRosterStart(object sender)
        {
            if (InvokeRequired)
            {
                // Windows Forms are not Thread Safe, we need to invoke this :(
                // We're not in the UI thread, so we need to call BeginInvoke               
                BeginInvoke(new ObjectHandler(xmppCon_OnRosterStart), new object[] { sender });
                return;
            }
            listEvents.Items.Add("OnRosterStart");
            listEvents.SelectedIndex = listEvents.Items.Count - 1;
        }

        void xmppCon_OnLogin(object sender)
        {
            if (InvokeRequired)
            {
                // Windows Forms are not Thread Safe, we need to invoke this :(
                // We're not in the UI thread, so we need to call BeginInvoke               
                BeginInvoke(new ObjectHandler(xmppCon_OnLogin), new object[] { sender });
                return;
            }
            listEvents.Items.Add("OnLogin");
            listEvents.SelectedIndex = listEvents.Items.Count - 1;
        }

        private void cmdLogin_Click(object sender, EventArgs e)
        {
            Jid jidUser = new Jid(txtJabberId.Text);

            xmppCon.Username = jidUser.User;
            xmppCon.Server = jidUser.Server;
            xmppCon.Password = txtPassword.Text;
            xmppCon.AutoResolveConnectServer = true;
            xmppCon.AutoRoster = true;


            xmppCon.Priority = 10;
            xmppCon.Port = 5222; //It hangs when I use 5222
            xmppCon.AutoRoster = true;
            xmppCon.AutoPresence = true;

            xmppCon.UseCompression = true;
            xmppCon.SocketConnectionType = agsXMPP.net.SocketConnectionType.Direct;
            xmppCon.UseStartTLS = false;
            xmppCon.Open();
        }

        private void cmdLogout_Click(object sender, EventArgs e)
        {
            // close the xmpp connection
            xmppCon.Close();
        }

        private void cmdSend_Click(object sender, EventArgs e)
        {
            // Send a message
            agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();
            msg.Type = agsXMPP.protocol.client.MessageType.chat;
            msg.To = new Jid(txtJabberIdReceiver.Text);
            msg.Body = txtMessage.Text;

            xmppCon.Send(msg);

            txtMessage.Text = "";
        }

     
    }
}
Again it doenst do anything at all .

Please have a look at the code and tell me if there is anything wrong. Also if you could answer my following questions:
1.) Which dll am I supposed to use?
2.) Am I supposed to change target platform and upgrade the project if I am using Visual studio 2008
3.) Can you send / point me (to) the correct dll
4.) do you have a guide or if somebody can post a working simple project to connect to google talk

Thanks for the help  :-)
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by ramraaj:
1.) Which dll am I supposed to use?
...
3.) Can you send / point me (to) the correct dll
the ones from the the binary CF *folders

Quote by ramraaj:
4.) do you have a guide or if somebody can post a working simple project to connect to google talk
it must work when you use the right dlls. Can you please post you Debug Xml output?

Alex
Avatar
ramraaj #3
Member since Dec 2009 · 4 posts
Group memberships: Members
Show profile · Link to this post
Hello Alex,
Thanks for prompt reply,

Again here is the code I am using followed by the XML Output

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using agsXMPP;
using System.IO;
using agsXMPP.protocol.client;

namespace testGoogleTalk
{
    public partial class Form1 : Form
    {
        XmppClientConnection xmpp = new XmppClientConnection();
        StreamWriter sw;
        public Form1()
        {
            InitializeComponent();
        }
               
      
       void xmpp_OnWriteXml(object sender, string xml)
        {
            sw.WriteLine("SEND XML: " + xml);
        }

       void xmpp_OnReadXml(object sender, string xml)
        {
            sw.WriteLine("REC XML: " + xml);
        }

        void xmpp_OnClose(object sender)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new ObjectHandler(xmpp_OnClose), new object[] { sender });
                return;
            }
            listEvents.Items.Add("OnClose Connection closed");
            listEvents.SelectedIndex = listEvents.Items.Count - 1;
            sw.Close();
        }

        void xmpp_OnError(object sender, Exception ex)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new ErrorHandler(xmpp_OnError), new object[] { sender, ex });
                return;
            }
            listEvents.Items.Add("OnError");
            listEvents.SelectedIndex = listEvents.Items.Count - 1;
        }

        void xmpp_OnAuthError(object sender, agsXMPP.Xml.Dom.Element e)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new XmppElementHandler(xmpp_OnAuthError), new object[] { sender, e });
                return;
            }
            listEvents.Items.Add("OnAuthError");
            listEvents.SelectedIndex = listEvents.Items.Count - 1;
        }

     private void button1_Click(object sender, EventArgs e)
        {
            sw = new StreamWriter("xmlDump.xml");
            xmpp.Server = "googlemail.com";
            xmpp.ConnectServer = "talk.google.com";
            xmpp.Port = 5222;
            xmpp.AutoResolveConnectServer = false;
            xmpp.Priority = 10;
            xmpp.AutoRoster = true;
            xmpp.AutoPresence = true;
            xmpp.UseCompression = true;
            xmpp.SocketConnectionType = agsXMPP.net.SocketConnectionType.Direct;
            xmpp.UseStartTLS = false;
            xmpp.Username = "username";
            xmpp.Password = "password";
            xmpp.OnReadXml += new XmlHandler(xmpp_OnReadXml);
            xmpp.OnWriteXml += new XmlHandler(xmpp_OnWriteXml);
            xmpp.OnError += new ErrorHandler(xmpp_OnError);
            xmpp.OnLogin += delegate(object o)
            {
                xmpp.Send(new Message
                    ("ahuja.ishmeet@gmail.com", MessageType.chat, "Hello, how are you?"));

            };
            xmpp.OnAuthError += new XmppElementHandler(xmpp_OnAuthError);
            xmpp.OnError += new ErrorHandler(xmpp_OnError);
            xmpp.OnClose += new ObjectHandler(xmpp_OnClose);
            xmpp.OnReadXml += new XmlHandler(xmpp_OnReadXml);
            xmpp.OnWriteXml += new XmlHandler(xmpp_OnWriteXml);
            xmpp.Open();
        }

   
    }
}

XML OutPut

SEND XML: <stream:stream to='googlemail.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
SEND XML: <stream:stream to='googlemail.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
REC XML: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="googlemail.com" version="1.0" id="636AD8A970124463" >
REC XML: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="googlemail.com" version="1.0" id="636AD8A970124463" >
REC XML: <stream:features xmlns:stream="http://etherx.jabber.org/streams"><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"><required /></starttls><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-GOOGLE-TOKEN</mechanism></mechanisms></stream:features>
REC XML: <stream:features xmlns:stream="http://etherx.jabber.org/streams"><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"><required /></starttls><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-GOOGLE-TOKEN</mechanism></mechanisms></stream:features>

And my final events are ;
OnError
OnError
OnConnectionClosed


What I did was to open a new visual studio 2008 SmartDevice Project
Add dlls (agXmpp and crypto) from  binary CF2 folders
and wrote the above code

Looking forward for your reply
Avatar
Alex #4
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I had problems as well earlier today to login to Google with the CF, but now it works without problems for me.

Alex
Avatar
ramraaj #5
Member since Dec 2009 · 4 posts
Group memberships: Members
Show profile · Link to this post
Quote by Alex:
I had problems as well earlier today to login to Google with the CF, but now it works without problems for me.

Alex


Hi Alex,

Thanks again for your reply but it doenst work for me. Not even on my emulator and not on my phone too. I am attaching my project which I am using. If you get time can you try running the attached project and see what the problem is . If you are able to make it run could you send me back the project. I will really appreciate it .

The settings which I am using is

Visual Studio 2008 with net 3.5
Windows mobile 6.1



http://www.mediafire.com/file/ymz0y2ytx2z/testGoogleTalk.zip

Well if not then I want you check these settings to see if they are ok.
sw = new StreamWriter("xmlDump.xml");
            xmpp.Server = "googlemail.com";
            xmpp.ConnectServer = "talk.google.com";
            xmpp.Port = 5222;
            xmpp.AutoResolveConnectServer = false;
            xmpp.Priority = 10;
            xmpp.AutoRoster = true;
            xmpp.AutoPresence = true;
            xmpp.UseCompression = true;
            xmpp.SocketConnectionType = agsXMPP.net.SocketConnectionType.Direct;
            xmpp.UseStartTLS = false;
            xmpp.Username = "username";
            xmpp.Password = "password";
            xmpp.OnReadXml += new XmlHandler(xmpp_OnReadXml);
            xmpp.OnWriteXml += new XmlHandler(xmpp_OnWriteXml);
            xmpp.OnError += new ErrorHandler(xmpp_OnError);
            xmpp.OnLogin += delegate(object o)
            {
                xmpp.Send(new Message
                    ("ahuja.ishmeet@gmail.com", MessageType.chat, "Hello, how are you?"));

            };
            xmpp.OnAuthError += new XmppElementHandler(xmpp_OnAuthError);
            xmpp.OnError += new ErrorHandler(xmpp_OnError);
            xmpp.OnClose += new ObjectHandler(xmpp_OnClose);
            xmpp.OnReadXml += new XmlHandler(xmpp_OnReadXml);
            xmpp.OnWriteXml += new XmlHandler(xmpp_OnWriteXml);
            xmpp.Open();

Thanks Alex :)
Avatar
Alex #6
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I will test your code tomorrow morning with my Google account.
I have only a gmail.com account, no googlemail.com account, but behind both domains should be running the same server code.

Have you tried your code on other public or local XMPP servers?

Alex
This post was edited on 2009-12-17, 18:17 by Alex.
Avatar
ramraaj #7
Member since Dec 2009 · 4 posts
Group memberships: Members
Show profile · Link to this post
Thanks Alex,

i Will look forward for your reply :)
Avatar
Alex #8
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I had no success to connect with the dll you are using in your project. But I have no problem to connect with the latest SVN code. I think we mad some changes for the Google X-Token Sasl mechanism a while ago. Your code looks correct, expect of the Xml handlers which you added twice.

You can download the latst binary here:
http://www.ag-software.net/downloads.html
its in the directory agsxmpp/binaries/CF3.5/

Please let me know if this works for you.

Alex
Avatar
Alex #9
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
we have a Beta version of MatriX Mobile now. Ping me by email or private mail if you want to test it.
MatriX Mobil has native TLS support. This means that no Google X-TOKEN authentication is needed and TLS work out of the box without bccrypto. There should be no problems to connect to GTalk.

Alex
Avatar
jmaines2 #10
Member since Feb 2010 · 13 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex,

I can't seem to get the samples included in the latest SVN to run. If I try to run the MiniClientWM5 example, it tells me that the agsXMPP_PPC dll is missing. I don't see this in any of the binaries. I've also tried porting the GTalk sample over to Windows Mobile; but I am never able to connect. The OnLogin event never fires. It does look like the socket connection is made but that is all. Any help you can provide would be greatly appreciated.
Avatar
Alex #11
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you have to reference the agsXMPP.dll from the CF folder.
Avatar
jmaines2 #12
Member since Feb 2010 · 13 posts
Group memberships: Members
Show profile · Link to this post
I have tried that; but OnLogin still does not fire. I'm basically using the GTalk code sample and attempting to port it to Windows Mobile.
Avatar
Alex #13
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
as discussed here before agsXMPP fails often to connect to Google Talk because Gtalk requires a secure connection and the Compact Framework still has no SslStream.
Please try other servers than Gtalk.
Avatar
jmaines2 #14
Member since Feb 2010 · 13 posts
Group memberships: Members
Show profile · Link to this post
Thanks. That makes sense now.
Avatar
jmaines2 #15
Member since Feb 2010 · 13 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #13
Does Matrix have this ability?
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: agsXMPP RSS