Ejemplo n.º 1
0
 public Client()
 {
     ConnectClient();
     this.stream = new ChatStream(client.GetStream());
     Read();
     Send();
 }
Ejemplo n.º 2
0
        public void Send_Click(object sender, RoutedEventArgs arg)
        {
            string message     = chatText.Text;
            string messageSend = User + ": " + message;

            if (message.Length <= 250)
            {
                ChatStream = chatClient.GetStream();        // connect to stream
                Byte[] sendBytes = new Byte[256];

                sendBytes = System.Text.Encoding.ASCII.GetBytes(messageSend);
                ChatStream.Write(sendBytes, 0, sendBytes.Length);       // send message

                chatText.Text = "";
                string chatMessage = "me: " + message;
                // create a listBox item
                chatBox.Items.Add(chatMessage);         // add chat to screen

                chatStream.Flush();
            }
            else
            {
                textError.Text = "You cannot exceed 250 characters";
            }
        }
Ejemplo n.º 3
0
        public ChatClient(string host, int port = 1300)
        {
            _currentpath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
            try
            {
                var tcpc   = Connect(host, port);
                var stream = tcpc.GetStream();
                _chatstream = new ChatStream(stream);
            }
            catch
            {
                Environment.Exit(0);
            }
            CheckForIllegalCrossThreadCalls = false;
            InitializeComponent();
            _cfont       = new Font("Arial", 14);
            _memberColor = new Hashtable();
            var tl = new Thread(Listen);

            tl.SetApartmentState(ApartmentState.STA);
            tl.Start();
        }
Ejemplo n.º 4
0
 public User(TcpClient client)
 {
     this.client = client;
     this.stream = new ChatStream(client.GetStream());
 }
Ejemplo n.º 5
0
 public Person(TcpClient client)
 {
     this.client = client;
     stream      = new ChatStream(client.GetStream());
 }