Untitled

mail@pastecode.io avatar
unknown
csharp
14 days ago
1.2 kB
8
Indexable
Never
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace ChatSystem.Net
{
    class Server
    {
        TcpClient _client;
        public Server()
        {
            _client = new TcpClient();

        }
        public void ConnectToServer()
        {
            if(!_client.Connected)
            {
                _client.Connect("127.0.0.1", 7891);
            }
        }
    }
}
//until here is the code that connects the client to the server.

using ChatSystem.MVVM.Core;
using ChatSystem.Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ChatSystem.MVVM.ViewModel
{
    class MainViewModel
    {
        public RelayCommand ConnectToServerCommand { get; set; }

        private Server _server;
        public MainViewModel()
        {
            _server = new Server();
            ConnectToServerCommand = new RelayCommand(o => _server.ConnectToServer());
        }
    }
}
// this code is the one that probably has the problem, its where the command that doesnt activate/work once i click the button
Leave a Comment