瀏覽代碼

Fixed Chat

Tom Remeeus 10 年之前
父節點
當前提交
5cdaf8282c

+ 10 - 2
Proftaak Remote Healthcare/FietsClientV2/Forms/PatientForm.cs

@@ -25,6 +25,11 @@ namespace FietsClient
             DataHandler.IncomingErrorEvent += HandleError; //initialize event
             DataHandler.IncomingErrorEvent += HandleError; //initialize event
 
 
             _connection.IncomingChatmessageEvent += new TcpConnection.ChatmassegeDelegate(printMessage);
             _connection.IncomingChatmessageEvent += new TcpConnection.ChatmassegeDelegate(printMessage);
+
+            //TIJDELIJK STUK CODE OM MESSAGE TE TESTEN
+            _connection.SendString("6|TOM|TOM|Je bent een homo");
+            Console.WriteLine("Bericht versturen");
+            //EINDE TESTCODE
         }
         }
 
 
         private void HandleError(string error)
         private void HandleError(string error)
@@ -112,9 +117,12 @@ namespace FietsClient
         {
         {
             if(messageBox.Text != null)
             if(messageBox.Text != null)
             {
             {
-                string message = messageBox.Text;
+                String[] data = new String[2];
+                data[0] = messageBox.Text;
+                data[1] = _connection.currentData.GetUserID();
                 messageBox.Clear();
                 messageBox.Clear();
-                _connection.SendChatMessage(message);
+
+                _connection.SendChatMessage(data);
             }
             }
         }
         }
 
 

+ 10 - 7
Proftaak Remote Healthcare/FietsClientV2/TCPConnection.cs

@@ -148,15 +148,18 @@ namespace FietsClient
 	
 	
 	public void SendChatMessage(string[] data)
 	public void SendChatMessage(string[] data)
         {
         {
-            String receiverID = data[1];
+            String receiverID = data[0];
 
 
-            if (currentData.GetUserID() == receiverID)
-            { 
-                String message = data[2];
+            if (currentData != null)
+            {
+                if (currentData.GetUserID() == receiverID)
+                {
+                    String message = data[1];
 
 
-                // send command ( cmdID | username sender | username patient | message )
-                string protocol = "6 | " + this.userID + " | " + receiverID + " | " + message;
-                SendString(protocol);
+                    // send command ( cmdID | username sender | username patient | message )
+                    string protocol = "6 | " + this.userID + " | " + receiverID + " | " + message;
+                    SendString(protocol);
+                }
             }
             }
         }
         }
 
 

+ 1 - 2
Proftaak Remote Healthcare/Server/Client.cs

@@ -103,10 +103,9 @@ namespace Server
                                 String sender = response_parts[1];
                                 String sender = response_parts[1];
 
 
                                 //bericht doorsturen naar alle actieve gebruikers (de Fietsclient zorgt ervoor dat alleen de geadresseerde het bericht kan zien)
                                 //bericht doorsturen naar alle actieve gebruikers (de Fietsclient zorgt ervoor dat alleen de geadresseerde het bericht kan zien)
-                                sendString("7|" + sender + "|" + receiver + "|" + message);
+                                sendString("7|" + sender + "|" + receiver + "|" + message);      
                             }
                             }
                             break;
                             break;
-                            
                     }
                     }
                 }
                 }
             }
             }