views:

66

answers:

2

Heya guys,

Iv'e pretty new to C# ATM and I seem to be having trouble with Jabber-Net

Im trying to create a basic chat application that will connect users via Jaber Services, the issues im having are with the Callbacks.

The main error I seem to get is about the "Event required but used like 'type'", or something along those lines..

Im at work atm so i cant give you full details but it seems to be when i try adding callbacks.. For example:

JabberClient Jabber = new JabberCLient();
Jabbaer.OnConnect += new jabber.connection.XmppStream.OnConnect(Some_event_function);

Now this code was just of the top of my head and may be wrong, i work by fixing errors as I'm learning but I get an error that basically telling me that what im doing should be done as an event but im using as a type

Can anybody shed some light on the matter please.

Regards Robert Pitt

A: 

Replace the second line with:

Jabber.OnConnect += Some_event_function;
Adrian Godong
Thanks for the fast reply, I cant test right now will do later, but i am sure I have attempted that method and got errors, I'm not 100% sure thou.
RobertPitt
If you got error, that's probably caused by signature difference (between the event and the callback).
Adrian Godong
Are those errors Catchable ?
RobertPitt
I don't think so, it should be compile error (caught at compile time). If you're referring to runtime error (.NET Exception), then something is wrong inside the function.
Adrian Godong
A: 

In principle, the line

  Jabbaer.OnConnect += new 
      jabber.connection.XmppStream.OnConnect(Some_event_function);

is wrong because XmppStream.OnConnect is a property and you need a delegate definition at that point. But instead of debugging what came from your memory, just use the shorthand form:

  Jabbaer.OnConnect += Some_event_function;
Henk Holterman
I will give that a try, I'm not sure why I was using the ` jabber.connection.XmppStream.OnConnect`, I'm sure somewhere I was told to. i will let you know soon the results.
RobertPitt