C# P2P chat application design - c#

I want to create a simple chat application that doesn't use an explicit server. The main requirement is that the user can simultaneously chat with many friends (just like on Skype etc.). I do not mean a conference chat here, just multiple separate chat-windows.
Currently, I want only a LAN messaging application but I'd appreciate, if the design was easy to extend to Internet connections.
I wonder what design is appropriate for such an application.
What do you think about a solution, where each user app has a TcpListener (the implicit server) and multiple TcpClient objects - one for each friend he/she is talking to.
What about authenticating the remote users? Should the chatting app generate a certificate (X509 or sth) or just assume that the users in a LAN are to be trusted :)
Kindest regards,

HttpListener + WebClient(or HttpWebRequest) can provide you more tools for authentication/security.
Basic Authentication, Ntlm, Integrated Windows Authentication, https etc. and they are more firewall friendly.

You should see start with
how do i make my own P2P software?
WCF / WPF Chat Application
P2P Communication - Proxy Listeners and Proxy Clients
Hope this proves good starting point
Happy coding

Related

How to create WPF internet chat application

I want to create a simple chat application using C# and WPF that uses internet to connect between clients and server. I found a lot of tutorials for chat apps, but they all work over local network, I am confused and don't know to what technology to use to create my app. Could anybody point me in the right direction?
You really have a lot of directions you can go for this. The simplest is a simple plain sockets client-server star topography. This will work over both a public and private network, but you will encounter data theft as the data will be unencrypted.
For any internet application, you really should use the SslStream to secure your communications between the server and client. This allows you to specify TLS1.2 as your transport which will provide great security. You can consume that server stream from WPF via standard Sockets or from Windows Store Apps using StreamSockets. Mind you, you will need to learn a LOT about how SSL keys work and configuring the connections in code.

communication between two emulators through server pc as middle man

i want to built an application which is communication network between two emulator. i have already connect emulator with server.
Now i want to connect two emulators through server(C#) which is PC. like we sent sms through mobile networks.
I need guidance to start this.
I am not sure what your requirements are and how far you would go to implement best practices, however, here are some points to consider based on my experience on a similar application, just to make it clear we worked on a solution where many Android phones would connect to a server to send/receive data.
Web Service is the way to go, this is what web services are meant for, we created WCF based APIs for the applications connecting to the server.
You are working on a heterogeneous system Java on Android, C# on the Server, consider creating REST based APIs on the server for data transfer
Go through these to get a feel of what needs to be done onthe server...
http://www.codeproject.com/Articles/105273/Create-RESTful-WCF-Service-API-Step-By-Step-Guide
http://msdn.microsoft.com/en-us/library/dd203052.aspx
And this for what needs to be done at Android side...
http://docs.xamarin.com/android/tutorials/consuming_web_services
hope that helps....

Chat (XMPP) messaging platform

I would like to encapsulate different messaging platforms (Google Talk, Facebook Chat) for my users - of course it will be using XMPP.
I will be writing the server in C# and the client in Flex (AIR).
Do I need to keep track of all the message in the server?
What would be the best practice for notifying users about a new message?
Polling?
Push? (How does C# works with Flex)
Thank you in advance...
You don't have to write a server at all. Your Flex (AIR) client has to connect to Facebooks or Googles XMPP server only. I suggest to pick a client library from here: http://xmpp.org/xmpp-software/libraries/ and start coding.

C#, WCF, want to make a chat application, what binding should I use? maybe some examples?

I am looking forward to make a sort of a chat application using C# and WCF, yet before I start I wanted to clear a few things, so that I don't get carried in the wrong direction. :)
the application should be able to both make event ( send messages ) and listen to events ( receive messages ), therefor if I understand it right, the application should be both the client and the server at once?
what binding should I use? If I understand right, basicHttp binding hard to configure and is used when a WCF app needs to connect to non-WCF app? While for connecting two WCF apps its better to use NetTcpBinding?
how would this applications find each other, considering that they are running on different machines? should there be a central server, to which the app would connect first, saying "I'm user123, my IP is that and that, I'm free for chat" and look for other user IP addresses there? Or is there some other ways for apps to find each other without the central server?
maybe you could direct me to some examples or tutorials on this topic? ( tried googling, no luck ).
Thanks! :)
If your peers (machine that can operate as a client & server) are going to be behind NATs/firewalls then you will have a very very tough time building a chat application using WCF. If the peers will all be on the same network WCF is workable.
To write a chat application from scratch using WCF you will be re-inventing the wheel. Why not employ an existing protocol that's been designed precisely for the purpose such as XMPP. There are XMPP libraries around for .Net. You will need a central server but if you use XMPP you could feasibly piggyback onto one of the many existing free servers.
You can use netPeerTcpBinding.
See also:
http://blogs.interknowlogy.com/2009/08/05/building-a-really-simple-wcf-p2p-application/
http://msdn.microsoft.com/en-us/library/bb690929(v=vs.90).aspx
http://www.codeproject.com/KB/WCF/Chat_application_using_WC.aspx
There is no right and wrong answer to your question - it all depends on what you require. You then can choose the best architecture for your needs, and then the best technology for that architecture.
There are two things to consider - how will users find people to chat to, and then once they have found someone - how do the applications connect to each other.
For users to find each other, you either need to connect to a central server, which will then show a list of all connected users, or users need to enter the IP address of the person they want to chat to. Note that some firewalls will block incoming connections in this second case, so this may not be feasible in some cases.
Next, once you have found the person you wish to chat to, you need to decide whether messages will route directly to the other user, or if you want to continue to go through a central server.
If you choose to go through a central server, then your application will be functioning as a client, and will therefore pass through firewalls without a problem. However if you connect directly to the other user, both copies of the application will be acting as a client and a server (P2P topology), and therefore firewalls may be an issue. Having said that, you could designate one of the applications to be a server, with the other acting as a client, in which case only the server side needs to worry about the firewall.
Without knowing exactly what you are trying to achieve, it is hard to recommend which architecture will work best for you.

Need help for a code to communicate between separate winform applications in C# over intranet:)

Can anyone help me with a coded example or any code to communicate between two separate application for multiple purposes like
i) Find server application on the intranet from a client application running as client
ii) Checking client or server is active from other side application
iii) Communication data or objects to the client or server from other side
I am using C# winforms and new to network applications so i need help.I preferred to ask this question here because i find more helpful links to help or guides than searching them over internet.
I agree that this is too big a subject for one question. However, to point you in the right direction, research WCF at the MSDN web site.
You could also do a search for ".Net Remoting" which is another way for .Net processes to communicate with each other by name over a network (or same machine).
Or you could go the Socket route and do something like multicast

Categories

Resources