WCF / WPF Chat Application

I have been using WPF for a bit, written about LINQ, but decided I should explore some of the other .NET 3.0 stuff.

To this end I have create a WPF / WCF chat application using all the good WCF stuff like callbacks etc etc.

You can see the application at codeproject or just follow this link.

Anyway it looks like this, oh I got a prize for this. People liked it.

wcfwpf.png

Advertisements

24 thoughts on “WCF / WPF Chat Application

  1. Daniel lee says:

    hi,

    I run this example in my machine,it’s great.
    now, I devolop a p2p chat, I want to use the p2p protocol, the server machine is in the internet, it works well in the intranet, but there is some troubles, if the two peer is in the different intranet, they can’t see each other, so can’t chat.
    so I want to know whether the WCF can p2p chat really,
    or I miss some steps in my code?

    thank you

  2. sacha says:

    sounds like a security thing, as WCF should be able to access an endpoint anywhere. peraps you need to look further at end point bindings in config files. perhaps the http binding would suit you better.

    have a look at that

    http://msdn2.microsoft.com/en-us/library/system.servicemodel.basichttpbinding.aspx

    Hope this helps, sorry that I cant spend more time helping on this issue

  3. Hi Sacha,

    Can you contact me please – regards your ‘cheeky bit’ on Codeproject.

    Regards

  4. Martin Wawrusch says:

    Hi Sacha,

    I’d like to talk to you, maybe you can send me an email.

  5. Just wanted to drop a message and say that I’ve followed your articles on codeproject and found them to be very helpful and informative.

    Keep up the good work!

    Thanks,
    Jon

  6. sacha says:

    Thanks very much appreciate that

  7. Karl Shifflett says:

    Sacha,

    I never knew you had a blog and when I got here, WOW!! What a surprise. I really need some sleep mate, but I’m holding to to read this blog!

    Hey, wanted to let you know that Team Mole just released Mole For Visual Studio. Mole now supports all Visual Studio project types, WPF, WCF, ASP.NET, WinForms! Prior releases of Mole targeted WPF developers.

    Code Project here, http://www.codeproject.com/KB/macros/MoleForVisualStudio.aspx (if you are a Code Project member, please vote for article. Remember, 5 is good)

    Mole’s Home Page : http://karlshifflett.wordpress.com/mole-for-visual-studio/

    The press we have received so far has been unbelievable.

    Thank you for passing the word about Mole!

    Best to your always. Cheers,

    Karl

  8. sacha says:

    Hi Karl,

    I dont really do as much on my blog as I should, maybe over XMAS ill write some more stuff up on here.

    The codeproject articles take so long to do, to be honest, and I would just be repeating information.

  9. Karl Shifflett says:

    Yes, I agree with the time involved with CP.

    I may look at enhancing my blog, make it nice like yours and post there.

    Maybe now that Mole development has quieted down, I can do this.

    Cheers,

    Karl

  10. sacha says:

    yeah its takes a lot of work old CP, but I like it, as it has a wider target audience than a single blog, so thats why I write stuff there 1st and foremost

  11. olcay cezayir says:

    Hi Sacha!!

    I have a senior project.It containes wpf chat over the internet…I have a short time to do this..so your project help me in right time.I have Visual Studio 2008 and Win XP.But with your project, If I run it, the command screen appears and it says

    “Chat service listen on endpoint net.tcp://localhost:22222/chatservice
    Press ENTER to stop chat service…

    and it waits with this.
    what is the problem..Please help me a.s.a.p.
    thanks for your pr

  12. pedram says:

    hello
    can you use a article to use this for a website

  13. sacha says:

    Sure the idea would be the same.

    Just change the WPF project for a ASP .NET one

  14. Jasvinder Bali says:

    Hi Sacha!
    I a trying extend your Chatter Application by adding Voice chat and getting the following problem.

    #. I capture the sound from microphone using Windows API. Then I continuously capture the sound from microphone and send the Audio stream (byte[]) to the server and broadcast from there. Its working fine and I also get the response from the server as well. Then I play the Audio Stream(byte[]) coming from the server.
    I used this article in codeproject website to record and play audio stream.
    http://www.codeproject.com/KB/audio-video/cswavrec.aspx
    But when the incoming audio stream is playing, an unrecognizable sound is coming. This may be due to the difference between data consuming and receiving rates.
    I also used directsound to record and playing sound but the same problem arise.
    So please suggest me how to solve this problem( Better DierctSound suggestion – Streaming Buffer) .
    This code is fire when audio stream is received from the server.
    private void playAudio()
    {
    objAudioConferencingPlayer.StartAudioPlayer(IncommingAudioStream);
    }
    public void StartAudioPlayer(byte[] AudioStream)
    {
    if (!IsPlayerRunning)
    {
    StopPlaying();
    m_Player = new WaveOutPlayer(-1, fmt, 16384, 3, new
    BufferFillEventHandler(Filler));
    IsPlayerRunning = true;
    }
    m_Fifo.Write(AudioStream, 0, AudioStream.Length);
    }

    private void Filler(IntPtr data, int size)
    {
    if (m_PlayBuffer == null || m_PlayBuffer.Length = size)
    m_Fifo.Read(m_PlayBuffer, 0, size);
    else
    for (int i = 0; i

  15. sacha says:

    This may have something to do with the buffer size at the server, you could try and up that to something bigger. This could be the issue. Change the Service configuration section of the App.Config.

  16. Ameer Kawar says:

    Hii,
    First I want to thank you for a great work.

    But I need help, I’m building an asp.net web project for me and I want to use your project with some changes,
    I need to send the Chat Name from my application so the user can’t choose his chat name.
    can you help me or guide me how to do this?

    Thanks in advance
    Ameer Kawar

  17. Ricardo says:

    Hello Sasha,

    I read your article in codeproject about this chat application, i like it very much! Congratulations.
    I create a simple chat project and it is working very nice, but i need to send a tcp message from a web page, and i can’t connect to the tcp server.

    Do you know if it is possible to do?

    Thank’s,
    Ricardo

  18. Thanks. development can be an excellent project. good day.

  19. Mumtaz says:

    hi,
    Iam exploring wcf.I have created a chat application using wcf in c#.net.It works properly but i want to add a feature where private chat between 2 clients must be allowed.When i send message all clients can view it.but what if i want to give a direct message to a particular client.Iam using netpeertcp.

    According to the concept i think, i will have to create a new chat mesh between 2 clients required to pass message.I need to use pnrp tp resolve the addresses of clients so that i can identify the peer to chat with.

    But i really dont knw how can i achieve this through code.iam new to wcf but know the concept as i went through number of msdn articles.how should i start the code?where should i write it?i just want a start n support so i can explore it further.

    I really would be pleased n thankful if u would help me in any way they can.can u give me link to directly contact u.waiting 4 your reply..
    THANKS.
    Mumtaz.

    • sacha says:

      I do not have time to “Help” anyone. I am too busy. This code has all you need and you are on right track. Best of luck

  20. Arsh says:

    Check out my chat application. You can download the client from http://arsh-virdi.com/Client.zip

    Hope you like it 🙂

  21. Tig says:

    I know you are really busy, but if you ever have time please answer my question:

    I have modified the WFC code of this chat application to use for my online card game networking.

    In this game, the player clicks the login button which creates a proxy, connects to server and sends the
    username and password which are [DataMember] in OnlinePlayer[Datacontract] class. The server authenticates and the player enters a lobby.
    The game starts when 4 players join a table.

    I am using WinForms. And the problem I am having is that when a player joins it is null on the server side but is instanciated on the client side.
    I have seperated the chat serverice and client projects and created a OnlinePlayer.cs for both of them.

    Here is where I get the error:

    lock (syncObj)
    {
    if (!checkIfOnlinePlayerExists(OnlinePlayer.Username) && OnlinePlayer != null) ——-> This is where I get the NullReferanceException

    What can be the problem? Do I need to convert my project to WPF so the WCF code of your chat application would work?
    Although, I copied all the WCF code from your chat application and it should’t be problem. The only difference is that I don’t call AddButtonClickEvent.

    Two other unrelated question if you don’t mind 🙂

    Is it easy to convert winForm to silverlight?

    And could I user your chat application WCF code with silverlight?

    The advantage with silverlight is that it can be run on browsers.

    • sacha says:

      Should have nothing to do with using WinForms. Though I don’t know what your issue could be, sorry to say.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: