Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
azdragon2 #1
Member since Sep 2009 · 5 posts
Group memberships: Members
Show profile · Link to this post
Subject: Setting up XmppClientConnection
Hey guys,

So I have a new project, am I'm trying to integrate agsXMPP.

Here's the code I have:
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. using agsXMPP;
  7. using agsXMPP.Xml;
  8. using agsXMPP.Xml.Dom;
  9.  
  10. namespace WindowsFormsApplication1
  11. {
  12.     public class GTalkSender
  13.     {
  14.         XmppClientConnection xmpp = new XmppClientConnection();
  15.        
  16.         xmpp.Server = "gmail.com";
  17.     }
  18. }

I have included agsXMPP2008 and agsXMPP2008.ui.2008 as projects alongside my new project. I also added the references agsXMPP2008 and agsXMPP2008.ui.2008 for my new project.

Here's the problem, the libraries exist and everything works fine, except that xmpp.Server = "gmail.com"; wont compile. It acts as if the object xmpp doesn't exist, and does not appear in the tooltip suggestions. Heres the error:

Error    1    Invalid token '=' in class, struct, or interface member declaration    C:\Documents and Settings\...\WindowsFormsApplication1\GTalkSender.cs


Any ideas?
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by azdragon2:
Any ideas?

yes, this is no valid c# code.
Avatar
azdragon2 #3
Member since Sep 2009 · 5 posts
Group memberships: Members
Show profile · Link to this post
I don't follow you, how is this not c# code?

Taken from the MiniClient C# example:

agsXMPP.XmppClientConnection XmppCon = new agsXMPP.XmppClientConnection();
           
XmppCon.Open();

Once again, XmppCon is not created and therefore I cannot call its function Open(). Yet the declaration of XmppCon is valid and will compile.

It would appear to me that the projects (agsXMPP2008, agsXMPP.ui.2008), although loaded and accessible, aren't properly setup and therefore unusable. I'm just hypothesizing though.

Any ideas?
Avatar
azdragon2 #4
Member since Sep 2009 · 5 posts
Group memberships: Members
Show profile · Link to this post
Also something to note, its not just XmppClientConnection,  its all classes.

So this will compile:
Jid j = new Jid("temp");

but I cannot access 'j'. Basically I cannot access any of the objects I create.


Are the examples they provide COM?

I am now thinking that the project type does not match with my project type and therefore the classes are read only.
This post was edited on 2009-09-23, 02:01 by azdragon2.
Avatar
Alex #5
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Error    1    Invalid token '=' in class, struct, or interface member declaration    C:\Documents and Settings\...\WindowsFormsApplication1\GTalkSender.cs

you cannot set object member variables in the declaration section. Either use c#3 object initializer, or set the members in a function or a constructor.

Solution 1:
  1. public class GTalkSender
  2. {
  3.     XmppClientConnection xmpp = new XmppClientConnection();
  4.  
  5.     public GTalkSender()
  6.     {
  7.         xmpp.Server = "gmail.com";
  8.     }
  9. }

Solution 2:
  1. public class GTalkSender
  2. {
  3.     XmppClientConnection xmpp = new XmppClientConnection{Server = "gmail.com"};
  4. }
This post was edited on 2009-09-23, 07:43 by Alex.
Avatar
azdragon2 #6
Member since Sep 2009 · 5 posts
Group memberships: Members
Show profile · Link to this post
I realized the extremely stupid mistake I was making. I didn't realize I wasn't writing in the constructor. I thought I was writing in the constructor, but really I was writing in the class declaration. Thanks for your help.
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:
Forum: agsXMPP RSS