Ejemplo n.º 1
0
        private void OnMsgTextReceived(object sender, TextMessageArgs e)
        {
            //selecting the required chatDisplay from contact
            ChatDisplay cd = contacts[e.msg.ipToken].chatDisplay;

            cd.addReceivedMessageToUI(e.msg);
        }
Ejemplo n.º 2
0
        public ContactTab(string token, string name)
        {
            InitializeComponent();
            nameText.Text  = name;
            tokenText.Text = token;
            chatDisplay    = new ChatDisplay(token, MiddleController.getInstance().fileShareController);

            //add previous msges or add previous chat display

            this.token = token;
        }
Ejemplo n.º 3
0
        public void addChatDisplayAndBrigFront(ChatDisplay cd)
        {
            if (cd != null)
            {
                container.Controls.Remove(currentChatDisplay);
                container.Controls.Add(cd);


                cd.Dock            = DockStyle.Right;
                currentChatDisplay = cd;
            }
        }
Ejemplo n.º 4
0
 private void Start()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(_instance.gameObject);
     }
     _instance = this;
     display   = GetComponent <ChatDisplay>();
     inputText.onEndEdit.AddListener(OnSendNewMessage);
     myPlayerName = PlayerPrefs.GetString("Name");
     DontDestroyOnLoad(gameObject);
 }
Ejemplo n.º 5
0
 private void Client_GotPrivateMessage(IrcMessage message)
 {
     // When the user receives a PRIVMSG command...
     BeginInvoke((Action)(() =>
     {
         // and if it is intended to be for this tab's target...
         if (message.args[0] == tabTarget)
         {
             // Display the message along with the sender.
             ChatDisplay.AppendText(message.sender + ": " + message.trail + "\r\n");
         }
     }));
 }
Ejemplo n.º 6
0
 private void chatBox_KeyUp(object sender, KeyEventArgs e)
 {
     // If the user pressed enter,
     if (e.KeyCode == Keys.Enter)
     {
         // Build a message object
         IrcMessage message = new IrcMessage(
             "PRIVMSG", new string[] { tabTarget }, chatBox.Text);               // PRIVMSG <nickname> <channel/user> :<message text>
         client.SendMessage(message);                                            // Send the message to the server,
         ChatDisplay.AppendText(client.Nickname + ": " + chatBox.Text + "\r\n"); // Display it on the client side,
         chatBox.Text = String.Empty;                                            // Then clear the chatbox.
     }
 }
Ejemplo n.º 7
0
 private void Client_OtherJoinedChannel(IrcMessage message)
 {
     // When another user joins the channel
     BeginInvoke((Action)(() =>
     {
         // and the message is for the tab's dedicated channel
         if (message.args[0] == tabTarget)
         {
             // Display a message
             ChatDisplay.AppendText(message.sender + " has joined " + tabTarget + "\r\n");
             // and add the user to the user list.
             userListBox.Items.Add(message.sender);
         }
     }));
 }
Ejemplo n.º 8
0
 private void Client_OtherPartedChannel(IrcMessage message)
 {
     // When another user parts from a channel
     BeginInvoke((Action)(() =>
     {
         // and if the message is for the tab's dedicated channel
         if (message.args[0] == tabTarget)
         {
             // Display a message
             ChatDisplay.AppendText(message.sender + " parted from " + tabTarget + "\r\n");
             // and remove the user from the list
             userListBox.Items.Remove(message.sender);
         }
     }));
 }
Ejemplo n.º 9
0
        //background work of sending message to client
        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            if (client.Connected)
            {
                write.WriteLine(texttosend);
                this.ChatDisplay.Invoke(new MethodInvoker(delegate ()
                {
                    ChatDisplay.AppendText("Me: " + texttosend + "\n");
                }));
            }
            else
            {
                MessageBox.Show("Sending failed");
            }

            backgroundWorker2.CancelAsync();
        }
Ejemplo n.º 10
0
        //background work of receiving message from client
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            while (client.Connected)
            {
                try
                {
                    texttorecieve = read.ReadLine();
                    this.ChatDisplay.Invoke(new MethodInvoker(delegate ()
                    {
                        ChatDisplay.AppendText("Client: " + texttorecieve + "\n");
                    }));

                    texttorecieve = "";
                }
                catch (Exception er)
                {
                    MessageBox.Show(er.Message.ToString());
                }
            }
        }
Ejemplo n.º 11
0
        public AudioRecorder(ChatDisplay cd)
        {
            InitializeComponent();

            path     = getPath();
            filePath = getPath() + "\\recorded" + DateTime.Now.Ticks + ".wav";

            recordingIcon.Visible = false;

            timer          = new Timer();
            timer.Interval = 25;
            timer.Tick    += timerTick;
            player         = new System.Media.SoundPlayer(filePath);

            timeLabel.Text = "";


            stopWatch = new Stopwatch();

            chatDisplay = cd;
        }
        //client side connection with sever
        private void button1_Click(object sender, EventArgs e)
        {
            client = new TcpClient();
            IPEndPoint ipconnection = new IPEndPoint(IPAddress.Parse(textBox1.Text), int.Parse(textBox2.Text));

            try
            {
                client.Connect(ipconnection);

                if (client.Connected)
                {
                    ChatDisplay.AppendText("Connected to Server" + "\n");
                    read            = new StreamReader(client.GetStream());
                    write           = new StreamWriter(client.GetStream());
                    write.AutoFlush = true;
                    backgroundWorker1.RunWorkerAsync();
                    backgroundWorker2.WorkerSupportsCancellation = true;
                }
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message.ToString());
            }
        }
Ejemplo n.º 13
0
 public void DisplayText(string text)
 {
     ChatDisplay.AppendText(text + "\r\n");
 }