How To Create a Chat App and Server Tutorial WPF C#

Поделиться
HTML-код
  • Опубликовано: 29 окт 2024

Комментарии • 162

  • @kay23456
    @kay23456 3 года назад +60

    This man has a video on how to make a discord ui as well as how to create a chat app.... he essentially just gave the power of remaking discord to everyone

    • @_buffer
      @_buffer  3 года назад +7

      You know it! :-)

  • @YidingHe
    @YidingHe 3 года назад +22

    As an experienced Java developer, I love these video tutorials that can take me into new languages quickly and efficiently.

  • @FiveNineO
    @FiveNineO 3 года назад +15

    The programming gods have blessed us brethren!

  • @energy-tunes
    @energy-tunes 3 месяца назад +3

    amazing, modern c# networking content seems to be lacking, this is a nice breath of fresh air

    • @_buffer
      @_buffer  2 месяца назад

      I'm glad you found it useful! :-)

  • @PavelS-m5r
    @PavelS-m5r Год назад +3

    Thank you so much. Your video helped a lot with my course project. I wouldn't have figured it out without you.

    • @_buffer
      @_buffer  Год назад +1

      I'm so glad you found this useful!

  • @Frusko
    @Frusko 3 года назад +15

    I absolutely love these videos. Please keep doing stuff like this, just watching you do stuff like this is helping me pick up better habits :D

    • @_buffer
      @_buffer  3 года назад +2

      That makes me so happy to hear! And More videos are coming your way! :-)

  • @Worthical
    @Worthical 3 года назад +5

    I swear my computer listens to my conversations and recommends this video and I aint mad at all!

    • @_buffer
      @_buffer  3 года назад

      Hahaha heck yeah! :D

  • @DemHP.
    @DemHP. Год назад +24

    For everyone who doesn't wanna write out the code at 6:25 here you go:
    namespace ChatClient.MVM.Core
    {
    class RelayCommand : ICommand
    {
    private Action execute;
    private Func canExecute;
    public event EventHandler CanExecuteChanged
    {
    add { CommandManager.RequerySuggested += value; }
    remove { CommandManager.RequerySuggested -= value; }
    }
    public RelayCommand(Action execute, Func canExecute = null)
    {
    this.execute = execute;
    this.canExecute = canExecute;
    }
    public bool CanExecute(object parameter)
    {
    return this.canExecute == null || this.canExecute(parameter);
    }
    public void Execute(object parameter)
    {
    this.execute(parameter);
    }
    }
    }

    • @kaanderin8382
      @kaanderin8382 Год назад +1

      i have 3 errors in this code idk why i did exactly same with video
      my errors are those
      ICommand
      CommandManager
      CommandManager
      can you help me

    • @drewcumpton1232
      @drewcumpton1232 Год назад +3

      @@kaanderin8382 Sounds like you need to add the namespace ' using System.Windows.Input; ' at the top. All 3 of those errors are in that namespace.

    • @kaanderin8382
      @kaanderin8382 Год назад +1

      @@drewcumpton1232 thank you man

    • @hubertromario4874
      @hubertromario4874 Год назад

      Where is the Icommadns interface file?

    • @rfatisler6500
      @rfatisler6500 Год назад +1

      @@hubertromario4874 using System.Windows.Input

  • @drewcumpton1232
    @drewcumpton1232 Год назад +9

    Great Vid, very instructional. One thing I would like to add, in the Packet Builder under the Write Message module, when using VS 17.4, you have to add 1 line to it, where you actually create a buffer and get a buffer length to get it to work properly. Well, at least for me this was the case, it may be a .Net version discrepancy also since 5.0 is no longer supported any more.
    public void WriteMessage(string msg)
    {
    byte[] buff = BitConverter.GetBytes(msg.Length);
    _ms.Write(buff, 0, buff.Length);

  • @oxygenfn5224
    @oxygenfn5224 Год назад +3

    You saved my programming class test, thank you so much, cant wait to see more of your videos I also learned so many new things :)

  • @DoomerCreatine
    @DoomerCreatine Месяц назад

    Thanks for all your videos! I mainly code via scripting for work (data analysis). So it's a lot of just taking random data formats in, manipulating them, and outputting them in a format for some other program. I've always wanted to give a shot at developing my own desktop apps and your videos made everything just make sense, especially with how MVVM works in the real world. Even though I mostly only know Python/R I was able to quickly pick up C#/XAML and have been able to make a good looking and functional websocket app for a streamer friend to help automate their stream chats!

  • @barryjohnson2756
    @barryjohnson2756 3 года назад +8

    Please continue to make videos like witch you create small wpf apps with their cool design. I hope you make a wpf app with database like SQlite and made a customer like app where you add/modify/delete/filter into database.That will be very helpful for me and a lot of people as well.

    • @_buffer
      @_buffer  3 года назад +2

      More on the way! :-)

  • @boost5207
    @boost5207 3 года назад +8

    This is amazing man. Thank you :) Definetily going to use this in my course project :)

  • @AkarumeiAkashi
    @AkarumeiAkashi Год назад +4

    1) It`s literally magnificent! Thank you so much, keep making such videos plz!
    2) How did you set-up the color theme in your visual studio, look`s great!
    3) Can this chat communicate over the Internet (computers are in different networks)?
    Thanks for video, one more time!

    • @drewcumpton1232
      @drewcumpton1232 Год назад +3

      It should be able to, 1 person can have the server, just make sure it uses your outside IP address, and unused port. Everyone else would need the client, and to have the correct IP address and port number to connect properly. And if the server is on a home network, you will need to make sure port forwarding for the selected port is forwarding to the correct internal IP address.

  • @DangDucCoder
    @DangDucCoder Год назад +4

    How to display multiple chat windows? My code is the same as in the video but it only displays 1 mainwindow window? Please help me answer. Please. Thanks

  • @ErenCode
    @ErenCode 3 года назад +4

    Better than my lectures! xD

  • @Gamoten2
    @Gamoten2 Месяц назад +1

    bro when clicked on Connect button => Server App Closed (crashed). also when i created project - i cant find .net 5 and last for me is 4.8.1 - can you think where is problem (my coding from 0 to 8 min of video)

  • @Cognitionz
    @Cognitionz 2 года назад +1

    Brilliant ^-^ Would love to see how to make a custom "server" for a group of people to join.

  • @ramzykaram296
    @ramzykaram296 Год назад

    This is one of the greatest tutorials ever, as a python developer that was the best tutorial on C#, sockets, and MVVC

  • @alisaeidalsheikh6451
    @alisaeidalsheikh6451 3 года назад +1

    thats so cool 😎
    Sir don’t you plan make full tutorial for C# form Beginning to advanced 🙏

  • @farrightcentrist7565
    @farrightcentrist7565 2 года назад +1

    Thanks for the great tutorial mate☺️

  • @all-dj
    @all-dj 3 года назад +5

    Senpai noticed me

    • @_buffer
      @_buffer  3 года назад +5

      Thai student has been noticed!

  • @DarkCloud0000
    @DarkCloud0000 2 года назад +1

    I love your videos they are nice ideas to work on👌🏻💙

    • @_buffer
      @_buffer  2 года назад

      Thank you! :-)

  • @Hadouken77
    @Hadouken77 3 года назад +7

    Hello, how did you create two instances of the MainWindow at around 38:25?

    • @_buffer
      @_buffer  3 года назад +4

      Good question! I opened up the bin folder and started the .exe from there :-)

    • @שוהםסיסו
      @שוהםסיסו 3 года назад +3

      in visual stidio you can rightclick a project and click debug then click start new instance and it will put another instance in debug mode instead if just openning an exe

  • @pedramkavian
    @pedramkavian 10 месяцев назад +2

    Maybe it's too late to question, but it seems to be a very simple text message app. What do you do when client wants to send different kinds of messages. Let's say he's sending a video to server. It's going to take a while until all bytes are sent to server and while sending the video he's going to send a text message as well. So, how your server is going to recognize what messages it's reading? Because it was busy reading the video data. Or maybe you must use another TcpClient for such scenarios?

    • @_buffer
      @_buffer  10 месяцев назад

      Good question!
      And compression the video is always a good idea, and another possibility is to create a thread per client and have ti run all of it's own work.

  • @Foxyzier
    @Foxyzier 3 года назад +2

    Maybe a follow up video with sending something like a message object with attachments, and to cache them on the client with the message history?

    • @_buffer
      @_buffer  3 года назад

      Good idea! :-)

  • @wearetheroyalsgames1464
    @wearetheroyalsgames1464 Год назад

    Great video thanks, this will really help with learning C# !
    p.s.
    at 31.06 with i got a error CS0052:
    public PacketReader PacketReader;
    i fixed it by making the:
    public class Server
    to an
    internal class server
    I don't know if anyone else got this problem or im just stupid, but if anyone got troubles with it you can try this.

  • @dra4hos757
    @dra4hos757 3 года назад +2

    the best one bro thanks a lot

    • @_buffer
      @_buffer  3 года назад +1

      You're most welcome :-)

  • @HighSkillxD
    @HighSkillxD 3 года назад +7

    Hello, I have a problem at 19:25. MemoryStream.Write need 3 parameter (byte[] buffer, int offset, int count). But in the video you only pass one parameter. Is there a solution for this?

    • @Shin_v2
      @Shin_v2 2 года назад

      Make sure that you are using .NET 5 or 6 (Core) and not .NET 4.X Framework.

    • @drewcumpton1232
      @drewcumpton1232 Год назад

      If you are using .NET 4.x framework, you can do the following:
      public void WriteMessage(string msg)
      {
      byte[] buff = BitConverter.GetBytes(msg.Length);
      _ms.Write(buff, 0, buff.Length);

  • @mohanadkiswany9501
    @mohanadkiswany9501 Год назад +1

    how can we make the clients are able to send a private message, i.e. they are able to select one of the users in the chat room in some way and only the designated user will receive the message?

  • @tacqz
    @tacqz 2 года назад +2

    Could you explain to me what the methods of the RelayCommand do? Just to understand it instead of just copying it?

    • @Luciferlep
      @Luciferlep 7 месяцев назад

      its kindda boiler code , so you have to mention it for the xaml and code to interact properly.

  • @wanderingtf2314
    @wanderingtf2314 2 года назад +1

    What were the usings for the RelayCommand class? You didn't show them in the video.

  • @ajyoldhamala
    @ajyoldhamala 8 месяцев назад +2

    How are you creating multiple instances of the running project?

    • @_buffer
      @_buffer  8 месяцев назад

      Good question! You could either set up the project to debug that way, or head into the bin folder and run another instance that way by running the executable. :-)

  • @theochasid8996
    @theochasid8996 2 года назад +1

    Thank you so much

    • @_buffer
      @_buffer  2 года назад

      You're most welcome!

  • @jonyoutubereal
    @jonyoutubereal 2 года назад +3

    Hey, great video overall but
    how do you not get errors for ICommand and CommandManager?

    • @dhruvakikkeri6217
      @dhruvakikkeri6217 2 года назад +1

      I got those errors too

    • @Xsnipe
      @Xsnipe 2 года назад +2

      add "using System.Windows.Input;" to the top

    • @ayyrax4154
      @ayyrax4154 Год назад

      @@Xsnipe u jus saved me bruv thank you

  • @ousstechfr5107
    @ousstechfr5107 3 года назад +2

    Great work, just a question, why you didn't use signalR ( or for learning purpose ) ?

    • @_buffer
      @_buffer  3 года назад +2

      Good question! Overly complicated for creating something so simple, as well as the fact that it just adds a bunch of unecessary abstraction while at the same time limiting the development experience, the only time I would actually use SignalR would be if I wanted to live update something in a web application :-)

    • @ousstechfr5107
      @ousstechfr5107 3 года назад +4

      ​@@_buffer you got a point, even if i disagree

    • @_buffer
      @_buffer  3 года назад +4

      @@ousstechfr5107 To each their own, whatever floats your boat and works for the project! :-)

  • @julie2586
    @julie2586 2 года назад +2

    Hey, is there a way for two computers on the same wifi to connect to the same server? I tried to change the IP address to my own but that doesn't work.

    • @_buffer
      @_buffer  2 года назад

      Should work just fine, feel free to hop on the Discord server and send me a message and I'll happily look into it! :-)

    • @imrxzey
      @imrxzey 2 года назад

      did you find out, cause i cant either

  • @swathy6819
    @swathy6819 3 года назад +2

    maybe a video on creating an animated wpf application?

    • @_buffer
      @_buffer  3 года назад +2

      That's actually on my list of video ideas! :D

  • @kaiserdrache7675
    @kaiserdrache7675 Год назад +1

    As of 27:00 the username can only be 4 characters in length, otherwise the server is forcfully shut down. I hope you fix this further in the video.

    • @nguyenhuuhanhlam
      @nguyenhuuhanhlam 10 месяцев назад

      small bug at WriteMessage func in PacketBuilder class, ms.Write(Encoding.ASCII.GetBytes(msg), 0, msg.Length); (not buff.Length)

  • @michalligezka5439
    @michalligezka5439 Год назад

    I finished writing out all of the code as in the video, everything works except for the messaging - it doesn't get sent through to the console or the program

  • @TheWasian
    @TheWasian 2 года назад +1

    Hey so are you able to combine the UI video with this one?

  • @MoviesChannelHdmovies4523
    @MoviesChannelHdmovies4523 5 месяцев назад +1

    How to display the multiple windows? Pls teach me i need this program 🙏🏻

    • @_buffer
      @_buffer  5 месяцев назад

      Feelf ree to join the Discord and we can discuss it further :-)

  • @venom_ftw9316
    @venom_ftw9316 Год назад +1

    Hi, thank you so much for this tutorial it has really helped me.
    However, I have a bug I cannot seem to fix. Whenever I send a packet, three characters of the string are omitted. My packet Reader and packet Builder classes are exactly the same as yours, as is most of the code I am using
    The issue gets solved when I just add three to the message length but I want a more solid solution. Thank you

    • @_buffer
      @_buffer  Год назад

      Hi! I'm glad you found it useful, it would be much easier to assist you on Discord :-)

    • @venom_ftw9316
      @venom_ftw9316 Год назад

      @@_buffer thank you for responding, I found out that the issue was because I called the wrong function 😂😂

  • @Lak1z
    @Lak1z 2 года назад +1

    This tutorial is very great! But I'm stuck on a 21:00 part... I receive an error "There is no argument given that corresponds to the required formal parameter 'offset' of 'MemoryStream.Write(byte[], int, int)"
    Did everything as in the tutorial but still getting this message....
    It is in PacketBuilder on ChatClient
    it shows me an error on :
    _ms.Write(BitConverter.GetBytes(msgLength));
    _ms.Write(Encoding.ASCII.GetBytes(msg));
    on "Write" sentence.. Could you help me please why do I receive this error?

    • @lazar3517
      @lazar3517 Год назад

      I have the same problem. Did you fix it?

    • @drewcumpton1232
      @drewcumpton1232 Год назад +1

      I should have looked at this sooner, I figured it out and posted it in my comment above, but I will put it here again.
      Great Vid, very instructional. One thing I would like to add, in the Packet Builder under the Write Message module, when using VS 17.4, you have to add 1 line to it, where you actually create a buffer and get a buffer length to get it to work properly. Well, at least for me this was the case, it may be a .Net version discrepancy also since 5.0 is no longer supported any more.
      public void WriteMessage(string msg)
      {
      byte[] buff = BitConverter.GetBytes(msg.Length);
      _ms.Write(buff, 0, buff.Length);

    • @drewcumpton1232
      @drewcumpton1232 Год назад

      @@lazar3517 See response above, hope this helps.

  • @saadhasnat3730
    @saadhasnat3730 2 года назад +1

    I am getting many errors in "RelayCommand" class, also in chatserver on "_listener". Did anyonle else face the same problem?

    • @drewcumpton1232
      @drewcumpton1232 Год назад

      I did at first, but found I was missing the namespaces for them, the RelayCommand class needs to have ' using System.Windows.Input; ' namespace, and then the _listener needs to have the ' using System.Net.Sockets; ' namespace. Start there, and see if it helps you progress with the program.

  • @HSS-pq6pi
    @HSS-pq6pi Год назад

    Hello I enjoyed your wonderful lecture! But how do I connect this chat app on another computer?

  • @WelshGuitarDude
    @WelshGuitarDude 2 года назад

    Would be nice to know what this ICommand interface is all about the code is some what confusing.

  • @hasanozan2393
    @hasanozan2393 Год назад

    I have error ;
    System.Windows.Markup.XamlParseException
    "Adding a value to a collection of type 'System.Windows.Controls.ItemCollection' returned an exception.' Line number '35' and line position '18'.'
    Inner Exception
    InvalidOperationException: The operation is not valid when using ItemsSource. use ItemsControl.ItemsSource instead to access and modify items.
    Can you help please.

  • @VSLComputers
    @VSLComputers 2 года назад +1

    How do you create a new project at all, much less a WPF app, in VS Code. I don't see these options.

    • @_buffer
      @_buffer  2 года назад

      Good question, you would have to use the CLI. I would highly recommend Visual Studio and not VS Code. :-)

    • @VSLComputers
      @VSLComputers 2 года назад

      @@_buffer Ah... I thought you were using VS Code. Thanks.

  • @ousspero
    @ousspero 3 года назад +1

    Nice job

    • @_buffer
      @_buffer  3 года назад +1

      Thank you! :-)

  • @不会打狙的小G
    @不会打狙的小G 8 месяцев назад +1

    terrific!🥰

    • @_buffer
      @_buffer  8 месяцев назад

      Thank you! :-)

  • @GhS_Ben
    @GhS_Ben 2 года назад +1

    Does is also work if i want to use ipv6?

  • @fai2834
    @fai2834 2 года назад

    I want the communication in UDP ,Is it easy to modify this to UDP?

  • @renukapriyadarshani2368
    @renukapriyadarshani2368 2 года назад +1

    Can you please tell me how did you open both two chat interfaces at one time in 27.47

    • @_buffer
      @_buffer  2 года назад

      Go into the bin folder, right click the solution > open folder in file explorer, and then it's in the bin folder

    • @drewcumpton1232
      @drewcumpton1232 Год назад

      @@_buffer Or you can right click on the ChatClient > debug > Start New Instance this will start another client

  • @qee5339
    @qee5339 Год назад

    i'm just stuck in that moment 8:05 if in video it at least showed error, in my situation it looks like it's not working at all because i have no error, no "connected" text (i decided to follow video a bit further cause i thought maybe program is working but it's not) it seems like a binding is not working, do i have to maybe install something on my visual or something else i simply have no clue how to make it work correctly

    • @floppaman4162
      @floppaman4162 Месяц назад

      I have the exact same problem if you know how to fix it pls reply

  • @rojetfacey5562
    @rojetfacey5562 2 года назад

    Hey I want some help I am currently stuck at 20mins in this video. I tried recreation this wpf but im have a problem with the WriteString function. Error code CS7036

    • @drewcumpton1232
      @drewcumpton1232 Год назад

      Not sure if anyone replied to you, but if they haven't, this is what I found.
      If you are using .NET 4.x framework, you can do the following:
      public void WriteMessage(string msg)
      {
      byte[] buff = BitConverter.GetBytes(msg.Length);
      _ms.Write(buff, 0, buff.Length);

  • @enterprisemusicoffical
    @enterprisemusicoffical 2 года назад +1

    When iam copying the code from PacketBuilder like in 27:06 it shows an error and _ms.Write is red marked please help me i tried everything

    • @kevincuppett5341
      @kevincuppett5341 2 года назад

      This is probably because you are using .NET Framework instead of .NET core. in .NET framework .Write() has more parameters than in Core.

    • @marslmaoo
      @marslmaoo 2 года назад

      @@kevincuppett5341 Do you know how to fix it and if so could you please tell me?

    • @kevincuppett5341
      @kevincuppett5341 2 года назад

      @@marslmaoo It would involve switching from the framework to .net core. I just remade the project from scratch. I can imagine there is a way to switch though.

    • @marslmaoo
      @marslmaoo 2 года назад

      @@kevincuppett5341 ok thanks

    • @drewcumpton1232
      @drewcumpton1232 Год назад

      @@marslmaoo If you are using .NET 4.x framework, you can do the following:
      public void WriteMessage(string msg)
      {
      byte[] buff = BitConverter.GetBytes(msg.Length);
      _ms.Write(buff, 0, buff.Length);

  • @joshfraser3991
    @joshfraser3991 3 года назад

    Great videos!

    • @_buffer
      @_buffer  3 года назад

      Thank you so much! :-)

  • @sharadranpara5449
    @sharadranpara5449 2 года назад

    Hi. Firstly. Thank you for the awesome tutorial. I love it!!
    I have a question. So we are doing this as a group project and when we try to connect together but we cannot chat or the server does not display the user joined. We are using different machines. Please tell me how we can solve that issue. Thanks

    • @Beste.TwitchClips
      @Beste.TwitchClips 2 года назад +1

      you need to be in the same network and you also need to change the host address to the machine that host the application

  • @ninjamateifort
    @ninjamateifort 3 года назад +2

    nice

  • @journalinspo
    @journalinspo Год назад

    Can i use this code to make a chat app in winforms?

  • @m3xpl4y
    @m3xpl4y 3 года назад +1

    AWESOME

  • @wargalokal9760
    @wargalokal9760 Год назад

    Cool video 🙌

  • @willsouza3048
    @willsouza3048 2 года назад

    What is this visual studio theme and how do i set this up?

  • @TECHN0HACKER
    @TECHN0HACKER Год назад +1

    Does this work over the internet?

    • @_buffer
      @_buffer  Год назад

      Good question! Yes!

  • @EnchikO
    @EnchikO 2 года назад

    Hello, what happened to your multiplayer game ?

  • @krasus7903
    @krasus7903 3 года назад +1

    bro i love you

  • @GameShorts484
    @GameShorts484 Год назад +1

    This is not a messaging app. you can't use it without in your local network. or you can type there a regular computer ip address

    • @_buffer
      @_buffer  Год назад +1

      You need to portforward the server and change the IP that the client connects to, it needs to connect to the server IP.

    • @lxcid3944
      @lxcid3944 6 дней назад

      use some common sense brother

  • @kumatoons5508
    @kumatoons5508 2 года назад

    can you add more to that modern chat app you made 4 months ago

  • @ascent3487
    @ascent3487 3 года назад

    can you teach how to make a log in page and connect the login page to the modern UI video you made

    • @שוהםסיסו
      @שוהםסיסו 3 года назад

      two methods ahed.
      if you create another window you can do new window().show() ; and it will create another window non blocking way and then you can do this.close(); and it will shut down the current window.
      another option is to set both views as user control and bind it to content control and change it in code. change will happend after validation in code and if you ise hosting you may even inject iy as a navigation service

  • @exec1337
    @exec1337 3 года назад +3

    you god?

    • @_buffer
      @_buffer  3 года назад +2

      I am not :relieved:

  • @sparrowin6570
    @sparrowin6570 7 месяцев назад

    Me wondering were did he gets an second Client

  • @noyxz
    @noyxz 2 года назад +1

    Is that only local?

    • @_buffer
      @_buffer  2 года назад

      No :-)

    • @noyxz
      @noyxz 2 года назад

      @@_buffer alright thanks so much!

  • @filipkaczmarek5697
    @filipkaczmarek5697 2 года назад

    Well, i know i need to learn this because deadline is looming but i am on 15th minute and my brain starts lagging

  • @luccck100
    @luccck100 5 месяцев назад +1

    Repository please?

    • @_buffer
      @_buffer  5 месяцев назад

      It's available on Patreon :-)

  • @marcelosilva6250
    @marcelosilva6250 2 года назад +1

    source code???

    • @_buffer
      @_buffer  2 года назад

      On my Patreon in the description :-)

    • @user_mmm
      @user_mmm 2 года назад

      @@_buffer but can this source code could be free?

    • @_buffer
      @_buffer  2 года назад

      @@user_mmm No, just like everyone else you need to get it from Patreon.

    • @user_mmm
      @user_mmm 2 года назад

      @@_buffer wheres grid in visual studio 2022?

  • @WelshGuitarDude
    @WelshGuitarDude 2 года назад +3

    I get: The name "MainViewModel" does not exist in the namespace "clr-namespace:ChatClient.MVVM.ViewModel" what did i get wrong here?

    • @drewcumpton1232
      @drewcumpton1232 Год назад +2

      I was having this issue too, I had to exit Visual Studio, and then open the project up again, and then build it.