@@ -182,12 +182,14 @@ static void Main(string[] args)
182182 SelectedChat = CurrentUser . Read_Messages_FileName ( SelectedChat ) ;
183183
184184
185+ string [ ] ChatContent = File . ReadLines ( @"chats\" + SelectedChat + ".txt" ) . ToArray ( ) ;
185186
186- string [ ] DecryptedChatContent = CurrentUser . Read_Messages_Chat ( SelectedChat ) ;
187+
188+ string [ ] DecryptedChatContent = CurrentUser . Read_Messages_Chat ( ChatContent ) ;
187189
188190 //User.Display.Content(DecryptedChatContent);
189191
190- Tuple < string , string > SymmetricKey = CurrentUser . Read_Chat_SymmetricKey ( SelectedChat ) ;
192+ Tuple < string , string > SymmetricKey = CurrentUser . Read_Chat_SymmetricKey ( ChatContent ) ;
191193
192194
193195 // while (true) { System.Threading.Thread.Sleep(5000); }
@@ -261,40 +263,63 @@ public static void PrivateChatLoop(string SelectedChat, Tuple<int, int> BoardDim
261263 TypedText = "" ; // Move this declaration outside the while loop
262264 string [ ] ChatMessages = { "TEMPVALUE" , "TEMPVALUE" } ;
263265
266+ string [ ] DecryptedMessages = { "TEMPVALUE" , "TEMPVALUE" } ;
267+
264268 TextListener . SetPointer ( 0 ) ;
265269 TextListener . SetTypedText ( " " ) ;
266270 TextListener . SetEndProgram ( false ) ;
267271
268272 TextListener . StartListening ( ) ;
269273 while ( true )
270274 {
271-
275+ // Console.WriteLine("start");
272276 Thread . Sleep ( 50 ) ;
273277
274- if ( TextListener . GetEndProgram ( ) ) {
275- if ( ! string . IsNullOrEmpty ( TypedText ) ) {
278+ if ( TextListener . GetEndProgram ( ) && ! string . IsNullOrEmpty ( TypedText ) ) {
276279
277280 if ( BadWords . BadWords . list . Any ( TypedText . Contains ) ) {
278281 Console . WriteLine ( "bad Word Found, Message not Sent" ) ;
279282 System . Threading . Thread . Sleep ( 1000 ) ;
280283 } else {
281- CurrentUser . Write_Messages_Chat ( SymmetricKey , SelectedChat , TypedText ) ;
284+ CurrentUser . Write_Messages_Chat ( SymmetricKey , SelectedChat , TypedText ) ;
282285
283- TextListener . StopListening ( ) ;
284- TextListener . SetTypedText ( "" ) ;
285- TextListener . SetEndProgram ( false ) ;
286- TextListener . StartListening ( ) ;
286+ TextListener . StopListening ( ) ;
287+ TextListener . SetTypedText ( "" ) ;
288+ TextListener . SetEndProgram ( false ) ;
289+ TextListener . StartListening ( ) ;
287290 }
288- }
289291 }
290292
291- //if (TypedText != TextListener.GetTypedText() || ChatMessages.SequenceEqual(ChatListener.GetChatContent())) {
293+ if ( TypedText != TextListener . GetTypedText ( ) ) {
294+
295+ // Console.WriteLine("text start");
292296
293297 TypedText = TextListener . GetTypedText ( ) ;
298+
299+ User . User . Display . Content ( DecryptedMessages , BoardDimensions , TypedText , true ) ;
300+ // Console.WriteLine("text end");
301+
302+ }
303+
304+ // Console.WriteLine("line");
305+ // Console.WriteLine(ChatMessages.Length);
306+ // Console.WriteLine("line");
307+ // Console.WriteLine(ChatListener.GetChatContent());
308+ // Console.WriteLine("line");
309+
310+ if ( ! ChatMessages . SequenceEqual ( ChatListener . GetChatContent ( ) ) ) {
311+
312+ // Console.WriteLine("chat start");
313+
294314 ChatMessages = ChatListener . GetChatContent ( ) ;
315+ DecryptedMessages = CurrentUser . Read_Messages_Chat ( ChatMessages ) ;
295316
296- User . User . Display . Content ( CurrentUser . Read_Messages_Chat ( SelectedChat ) , BoardDimensions , TypedText , true ) ;
297- //}
317+
318+ User . User . Display . Content ( DecryptedMessages , BoardDimensions , TypedText , true ) ;
319+ // Console.WriteLine("chat end");
320+
321+ }
322+ // Console.WriteLine("end");
298323 }
299324 }
300325}
0 commit comments