예제 #1
0
 /// <summary>
 /// Deep clone of a ChatSocket object without the network stream cloned.
 /// It is used when a new ChatSocket object is passed on to methods, events that
 /// do not need a network stream.
 /// </summary>
 public ChatSocket(ChatSocket cp)
 {
     this.target        = cp.Target;
     this.command       = cp.Command;
     this.metatype      = cp.Metatype;
     this.metadata      = cp.Metadata;
     this.sentBytes     = cp.SentBytes;
     this.receivedBytes = cp.ReceivedBytes;
 }
예제 #2
0
        /// <summary>
        /// A ClientManager is responsible for managing a connection from a client.
        /// For each client connected there will be one separate ClientManager object.
        /// The socket used by the ClientManager uses asynchronous call to Receive and
        /// send data.
        /// </summary>
        public ClientManager(ref Socket clientSocket)
        {
            if (clientSocket == null)
            {
                throw new Exception("Client socket is not initialized!");
            }

            // the endpoint stores information from the client side
            socket   = clientSocket;
            endPoint = (IPEndPoint)socket.RemoteEndPoint;

            // create the ChatSocket
            chatSocket               = new ChatSocket(ref socket);
            chatSocket.Received     += new EventHandler(OnChatSocketReceived);
            chatSocket.Disconnected += new EventHandler(OnChatSocketDisconnected);

            chatSocket.Receive();
        }