public ConnectedClient(int id, Socket tcpSocket, List <BookInServer> clientBookList)
 {
     MessageSerializer = new MessageSerialier();
     this.ClientID     = id;
     this.TcpSocket    = tcpSocket;
     ClientBookList    = clientBookList;
 }
Beispiel #2
0
        public Client(int clientID, List <Book> books)
        {
            ClientID                = clientID;
            TcpSocket               = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            ListenTcpThread         = new Thread(ListenTcp);
            ClientMessageSerializer = new MessageSerialier();
            SetBookInServerList(books);
            IPEndPoint serverIPEndPoint = new IPEndPoint(IPAddress.Parse(ServerIP), ServerPort);

            TcpSocket.Connect(serverIPEndPoint);
            ListenTcpThread.Start();

            IPEndPoint        clientIp          = (IPEndPoint)(TcpSocket.LocalEndPoint);
            ConnectionRequest connectionRequest = new ConnectionRequest(clientIp.Address.ToString(), clientIp.Port, clientID, BookInServerList);

            SendMessage(connectionRequest);
        }
Beispiel #3
0
 public Server()
 {
     MessageSerializer = new MessageSerialier();
     clientsList       = new List <ConnectedClient>();
     tcpListenThread   = new Thread(ListenTCP);
 }