ConnectionEstablished event

43 views
Skip to first unread message

Luis Reis

unread,
Sep 9, 2012, 7:26:43 PM9/9/12
to msnp...@googlegroups.com
The ConnectionEstablished event is being triggered twice using TCP although in HTTP it just triggers once as expected. My code is exactly the when I use either one of the dlls in which the only change made was changing Settings.DisableHttpPolling=false to true. I'm 100% sure that the .Connected() is only called once and the only thing that the ConnectionEstablished procedure does is to print a string. Is this the intended behaviour or is it a bug?

Pang WU

unread,
Sep 10, 2012, 3:03:44 PM9/10/12
to msnp...@googlegroups.com
It should be a bug, did you try out the latest code in the git repo?

Pang WU

unread,
Sep 10, 2012, 3:16:23 PM9/10/12
to msnp...@googlegroups.com
Hi there,

I tried this out in example client, it only triggered once.
I think the reason you have this problem might be two-fold: 1) You have a very old MSNPSharp lib. 2) Your code have problem.

Please check out the latest code from our git repo and test the example client, if that client doen't have this behavior, you may want to check your code then.



On Sunday, 9 September 2012 16:26:43 UTC-7, Luis Reis wrote:

Luis Reis

unread,
Sep 10, 2012, 4:34:22 PM9/10/12
to msnp...@googlegroups.com
Hi there,
 
Just tried with latest from GIT, I was using 5.04 because didn't think the change was relevant but anyway the problem persists. I've rebuilded the dlls again with both HTTP and TCP polling (before I had builded myself TCP only and HTTP was downloaded) to test if it was because I was building with VS 2012 but it seems that's not the case. Did you test with any option I don't know about that uses TCP instead of HTTP using the same dll or did you build a new dll with Settings.DisableHttpPolling=true?

Luis Reis

unread,
Sep 10, 2012, 5:49:02 PM9/10/12
to msnp...@googlegroups.com
Just tried the example client and it still happens. I added a messagebox to the connectionestablished, when using http 1 messagebox pops and when using tcp 2 messagebox pop.

Luis Reis

unread,
Sep 10, 2012, 5:55:01 PM9/10/12
to msnp...@googlegroups.com
By the way forget about the noob chat about compiling the dll with Settings.DisableHttpPolling=true. I thought I had to modify the MSNPSharp source and compile different dlls but I just found out that I can also use it in my code for the same effect :)

Pang Wu

unread,
Sep 10, 2012, 8:07:55 PM9/10/12
to msnp...@googlegroups.com
Hi Luis,

Can you share me the code of  the messagebox?

Pang Wu

unread,
Sep 10, 2012, 8:09:30 PM9/10/12
to msnp...@googlegroups.com
I just uncomment // Settings.DisableHttpPolling = true; in example client's ClientForm() constructor.

Pang Wu

unread,
Sep 10, 2012, 8:10:36 PM9/10/12
to msnp...@googlegroups.com
btw, I am testing it with Mono on a Mac, but I don't think this will cause the difference.

Luis Reis

unread,
Sep 10, 2012, 8:16:39 PM9/10/12
to msnp...@googlegroups.com
I tested it by adding      MessageBox.Show("string");     to NameserverProcessor_ConnectionEstablished in DotMSNClient.cs. When you use TCP don't you see 2 boxes popping up?

Pang WU

unread,
Sep 11, 2012, 1:24:44 AM9/11/12
to msnp...@googlegroups.com
If your code looks like following:

private void NameserverProcessor_ConnectionEstablished(object sender, EventArgs e){

MessageBox.Show("String");

            if (InvokeRequired)

            {

                BeginInvoke(new EventHandler(NameserverProcessor_ConnectionEstablished), sender, e);

                return;

            }


            SetStatus("Connected to server");

        }



You are for sure getting two message boxes because the BeginInvoke(new EventHandler(NameserverProcessor_ConnectionEstablished), sender, e); call this method again. For TCP the data was delivered in a thread that differ from the UI thread, that's why we need that line. And this is not a bug, please read more about C# UI sync.

Luis Reis

unread,
Sep 11, 2012, 9:50:23 AM9/11/12
to msnp...@googlegroups.com
void ConnectionEstablished(Object sender, EventArgs e)
{
   f.Invoke((MethodInvoker)delegate { f.print("Connection established"); });
}
 
That's the code I've been using and printing "Connection established" twice for TCP and once for HTTP.
 
If you say it's because of the     BeginInvoke(new EventHandler(NameserverProcessor_ConnectionEstablished), sender, e);     try deleting the whole "If" that has the     BeginInvoke(new EventHandler(NameserverProcessor_ConnectionEstablished), sender, e);     including everything inside the "if" and add     MessageBox.Show("string");     in the procedure.
When the first box appears you click ok and then you will see another box popping up.
 
Btw besides the ISP blocking problem mentioned somewhere and the fact that the account stays online after internet disconnection 10 secs for HTTP and almost 2 mins for TCP, what's the difference between TCP and HTTP? Any behaviour change or connection speed or messaging latency?
Message has been deleted

Pang WU

unread,
Sep 15, 2012, 8:14:38 PM9/15/12
to msnp...@googlegroups.com
Hi,

I repeated your issue. The event was triggered twice because TCP connection was redirected by the server. This is the normal behavior of MSN clinet-server login interaction.
Reply all
Reply to author
Forward
0 new messages