Exemplo n.º 1
0
 private static void TextMessagePacketHandler(byte[] receivedPacket, Socket clientSocket)
 {
     try
     {
         if (wasTheMessageEverReceived == false)
         {
             wasTheMessageEverReceived = true;
             TextMessagePackage textMessagePackage = new TextMessagePackage(receivedPacket);
             NewMessageForm.ReceiveMessage(textMessagePackage.textMessage);
             NewMessageForm.ShowDialog();
             NewMessageForm.Focus();
         }
         else
         {
             TextMessagePackage textMessagePackage = new TextMessagePackage(receivedPacket);
             //NewMessageForm.Activate();
             NewMessageForm.ReceiveMessage(textMessagePackage.textMessage);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ne mogu primiti poruku od Servera!");
     }
 }
Exemplo n.º 2
0
        private static void TextMessagePacketHandler(byte[] receivedPacket, Socket clientSocket)
        {
            //Radimo konverziju primljenog paketa (lambda expressions)
            TextMessagePackage textMessagePackage = new TextMessagePackage(receivedPacket);

            //Identificiramo klijenta koji je poslao poruku po socketu
            Client clientThatSentMessage = clientList.Find(client => client.clientSocket == clientSocket);

            if (!openedMessageForms.ContainsKey(clientSocket))
            {
                MessageForm NewMessageForm = new MessageForm(clientSocket);
                openedMessageForms.Add(clientSocket, NewMessageForm);
                NewMessageForm.ReceiveMessage(textMessagePackage.textMessage, clientThatSentMessage.clientComputerName);
                NewMessageForm.ShowDialog();
                //Application.Run();
            }
            else
            {
                MessageForm NewMessageForm = openedMessageForms[clientSocket];
                //NewMessageForm.ShowDialog();
                //NewMessageForm.Activate();
                NewMessageForm.ReceiveMessage(textMessagePackage.textMessage, clientThatSentMessage.clientComputerName);
            }
        }
Exemplo n.º 3
0
        private static void TextMessagePacketHandler(byte[] receivedPacket, Socket clientSocket)
        {
            //Radimo konverziju primljenog paketa (lambda expressions)
            TextMessagePackage textMessagePackage = new TextMessagePackage(receivedPacket);
            
            //Identificiramo klijenta koji je poslao poruku po socketu
            Client clientThatSentMessage = clientList.Find(client => client.clientSocket == clientSocket);

            if (!openedMessageForms.ContainsKey(clientSocket))
            {
                MessageForm NewMessageForm = new MessageForm(clientSocket);
                openedMessageForms.Add(clientSocket, NewMessageForm);
                NewMessageForm.ReceiveMessage(textMessagePackage.textMessage, clientThatSentMessage.clientComputerName);
                NewMessageForm.ShowDialog();                
                //Application.Run();                
            }
            else
            {
                MessageForm NewMessageForm = openedMessageForms[clientSocket];
                //NewMessageForm.ShowDialog();
                //NewMessageForm.Activate();
                NewMessageForm.ReceiveMessage(textMessagePackage.textMessage, clientThatSentMessage.clientComputerName);
            }
        }