Advertisement
Guest User

Untitled

a guest
Mar 7th, 2022
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.30 KB | None | 0 0
  1. unit cMRCClient;
  2.  
  3. {$mode ObjFPC}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8. Classes, SysUtils, cTelnetServer, IDContext, IdTCPClient, IDTCPConnection, IDThreadSafe, strutils, programinfo, baseunix, ansi, cyberio, userhandler, dateutils;
  9.  
  10. type
  11. TStringDynArray = array of string;
  12.  
  13. {
  14. type
  15. ClientLoadThread = class(TThread)
  16.  
  17. class var
  18. // Client : IdTCPClient.TIdTCPClient;
  19.  
  20. protected
  21. class procedure Execute;
  22. public
  23. // Constructor Create(CreateSuspended : boolean);
  24. end;
  25. }
  26.  
  27. type TReadingThread = class(TThread)
  28. protected
  29. FConn: TIdTCPConnection;
  30. FQueue: TIdThreadSafeStringList;
  31. procedure Execute; override;
  32. public
  33. constructor Create(AConn: TIdTCPConnection; AQueue: TIdThreadSafeStringList);
  34. end;
  35.  
  36.  
  37.  
  38. {
  39. ...
  40.  
  41. Msgs := TIdThreadSafeStringList.Create;
  42. Client.Connect;
  43. Thread := TReadingThread.Create(Client, Msgs);
  44. }
  45.  
  46.  
  47.  
  48. //Forward Declared
  49.  
  50.  
  51. procedure DrawScreen();
  52. function MRCPrompt(): string;
  53. procedure SendMsg(sMsg: string);
  54. procedure PrintHelp();
  55. procedure PrintContent;
  56. procedure ShiftArray;
  57. procedure AddContent(sInput: string);
  58. procedure ClearAll;
  59. procedure ClearLine(iLine: integer);
  60. procedure CheckMsgs();
  61.  
  62.  
  63. //Client Functions
  64. procedure SENDALIVE();
  65.  
  66.  
  67. procedure BroadCastMsg(sMsg: string);
  68. procedure Quit();
  69. function LoadMsgs(sMsg: string): integer;
  70. function ParseMessage(sMessage: string): TStringDynArray;
  71. procedure SendIAMHERE();
  72. procedure SetPrompt;
  73. function Sanitize(sStringGiven: string): string;
  74.  
  75. //System Commands
  76. procedure JoinMRC();
  77. procedure cmd_SHOWMRCDIR();
  78.  
  79. //Commands
  80. procedure cmd_BBSES();
  81. procedure cmd_ROOM();
  82. procedure cmd_USERS();
  83. procedure cmd_ROOMLIST();
  84.  
  85.  
  86.  
  87.  
  88. procedure StartMRC();
  89.  
  90.  
  91. implementation
  92.  
  93.  
  94.  
  95.  
  96.  
  97. uses
  98. MainMenu;
  99.  
  100. threadvar
  101. cMultiPlexerClient: IdTCPClient.TIdTCPClient;
  102. //LoadThread: ClientLoadThread;
  103.  
  104. ContentArray: array [0..20] of string;
  105. sReturnString: string;
  106. sRoom: string;
  107. boolNewMessages: boolean;
  108. IAMHERECnt: integer;
  109. Msgs : TIdThreadSafeStringList;
  110. Thread : TReadingThread;
  111.  
  112.  
  113. {
  114. class procedure ClientLoadThread.Execute;
  115. begin
  116. CheckMsgs(self.Client);
  117. end;
  118. }
  119.  
  120. constructor TReadingThread.Create(AConn: TIdTCPConnection; AQueue: TIdThreadSafeStringList);
  121. begin
  122. inherited Create(False);
  123. FConn := AConn;
  124. FQueue := AQueue;
  125. end;
  126.  
  127. procedure TReadingThread.Execute;
  128. begin
  129. while not Terminated do
  130. begin
  131. FQueue.Add(FConn.IOHandler.ReadLn);
  132. end;
  133. end;
  134.  
  135.  
  136.  
  137. //Start MRC
  138. procedure StartMRC;
  139.  
  140. begin
  141.  
  142. Msgs := TIdThreadSafeStringList.Create;
  143.  
  144. Thread := TReadingThread.Create(cMultiPlexerClient, Msgs);
  145.  
  146. //Start Client
  147. cMultiPlexerClient := IdTCPClient.TIdTCPClient.Create;
  148. cMultiPlexerClient.Host := programinfo.cbbsServicesIni.Mrc_Server_Hostname;
  149. cMultiPlexerClient.Port := programinfo.cbbsServicesIni.Mrc_Port.ToInteger;
  150.  
  151. cMultiPlexerClient.Connect();
  152. // cMultiPlexerClient.IOHandler.RecvBufferSize := 1; //Set Recv Buffer To 1 (Turn off buffering of input of client)
  153. cMultiPlexerClient.IOHandler.ReadTimeout:=0;
  154. sleep(250);
  155.  
  156. //Start Thread With Client
  157. Thread := TReadingThread.Create(cMultiPlexerClient, Msgs);
  158.  
  159.  
  160. //Set Variables
  161. ansi.PipeClrScr;
  162. JoinMRC();
  163. SendAlive();
  164. DrawScreen();
  165. MRCPrompt();
  166.  
  167. end;
  168.  
  169.  
  170. //Draw Blank Screen
  171. procedure DrawScreen();
  172. begin
  173.  
  174. gotoxy(1, 1);
  175. ansi.DrawDoubleLine(BrightCyan, 80);
  176. gotoxy(1, 7);
  177. cyberio.PipeWriteString('|14[ |15CyberBBS V.' + programinfo.sProgVersion + ' MRC Client |14]');
  178. gotoxy(23, 1);
  179. ansi.DrawDoubleLine(BrightCyan, 80);
  180. gotoxy(23, 65);
  181. cyberio.PipeWriteString('|14[ |15[/?] Help |14]');
  182.  
  183. end;
  184.  
  185. //Input MRC Prompt
  186. function MRCPrompt(): string;
  187. var
  188. ByteInput: byte;
  189. chInput: char;
  190. sSendMsg: string;
  191. boolReturn: boolean;
  192. sRecvData: string;
  193.  
  194. begin
  195. boolReturn := False;
  196.  
  197. gotoxy(24, 1);
  198. cyberio.PipeWriteString('|14[-> |15');
  199. gotoxy(24, 5);
  200.  
  201.  
  202. cyberio.SetPromptTimeout(0);
  203. repeat
  204.  
  205. ByteInput := 0;
  206.  
  207. chInput := ' ';
  208.  
  209. cyberio.PipeWriteString('|15'); //Set Gray Color
  210. //Code To Get String (Char by Char - Byte);
  211.  
  212. // if (cContext.Connection.IOHandler.CheckForDataOnSource(1)) then
  213. //PrintContent;
  214. //SetPrompt;
  215. chInput := cContext.Connection.IOHandler.ReadChar();
  216.  
  217.  
  218. // PrintContent();
  219. while (cContext.Connection.IOHandler.CheckForDataOnSource(10)) do
  220. begin
  221. chInput := cContext.Connection.IOHandler.ReadChar();
  222. end;
  223.  
  224.  
  225. if (chInput <> chr(0)) then
  226. begin
  227. case (chInput) of
  228. chr(byte(255)):
  229. begin
  230. write('255 sent');
  231. if (cyberio.PipeReadByte() = 241) then
  232. begin
  233. chInput := chr(0);
  234. cyberio.PipeReadByte();
  235. cyberio.PipeReadByte();
  236. cyberio.PipeReadByte();
  237. cyberio.PipeReadByte();
  238. cyberio.PipeReadByte();
  239. cyberio.PipeReadByte();
  240. cyberio.PipeReadByte();
  241. cyberio.PipeReadByte();
  242. cyberio.PipeReadByte();
  243.  
  244. end;
  245.  
  246. end;
  247.  
  248.  
  249. //cyberio.PipeReadByte(); // Read and flush IAC + After Bytes //IAC
  250. //chr(241): begin chInput :=chr(0); cyberio.PipeReadByte(); cyberio.PipeReadByte(); chInput := chr(0); end;//NOP (NetRuner 19+ Beta Polls these
  251.  
  252.  
  253. #32.. #125:
  254. begin
  255.  
  256. if (length(sReturnString) < 76) then
  257. begin
  258. //Add To String
  259. // sReturnString := sReturnString + chr(Ord(ByteInput));
  260. sReturnString := sReturnString + chInput;
  261.  
  262. //Print Character
  263. // cyberio.PipeWriteChar(chr(Ord(ByteInput)));
  264. cyberio.PipeWriteChar(chInput);
  265.  
  266. //Set Byte To Nothing
  267. // ByteInput := 0;
  268. chInput := chr(0);
  269.  
  270. end;
  271. end;
  272. #8, #127:
  273. begin
  274.  
  275. if (length(sReturnString) > 0) then
  276. begin
  277. //Delete One Char From String
  278. Delete(sReturnString, length(sReturnString), 1);
  279. cyberio.AnsiMoveLeft1;
  280. cyberio.PipeWriteString(' ');
  281. cyberio.AnsiMoveLeft1;
  282. byteinput := 0;
  283. chInput := chr(0);
  284.  
  285. end;
  286.  
  287. end;
  288. //handle ESC
  289. #27:
  290. begin
  291. cyberio.PipeFlushBuffer4B;
  292. sleep(250);
  293. cyberio.PipeFlushBuffer4B;
  294. sleep(250);
  295. cyberio.PipeFlushBuffer4B;
  296. sleep(250);
  297. cyberio.PipeFlushBuffer4B;
  298. ByteInput := 0;
  299. chInput := chr(0);
  300. end;
  301.  
  302.  
  303. //Handle Other
  304. #1.. #7, #9, #11, #12, #14.. #26, #28.. #31:
  305. begin
  306. cyberio.PipeFlushBuffer4B;
  307. sleep(250);
  308. cyberio.PipeFlushBuffer4B;
  309. sleep(250);
  310. cyberio.PipeFlushBuffer4B;
  311. sleep(250);
  312. cyberio.PipeFlushBuffer4B;
  313. ByteInput := 0;
  314. chInput := chr(0);
  315.  
  316. end;
  317.  
  318. #0:
  319. begin
  320. chInput := ' ';
  321. end;
  322. #10, #13:
  323. begin
  324.  
  325. case (sReturnString) of
  326.  
  327. //System Commands
  328. '/?', '/help': PrintHelp();
  329. '/quit', '/q': Quit();
  330. '/cls', '/clear', '/c': ClearAll();
  331. '/showmrcdir': cmd_SHOWMRCDIR();
  332.  
  333. //Custom Commands
  334. '/bbses', '/connected': cmd_BBSES();
  335. '/room': cmd_ROOM();
  336. '/users', '/u': cmd_USERS();
  337. '/rooms', '/r/': cmd_ROOMLIST();
  338.  
  339. //Fun Commands
  340.  
  341. else
  342. begin
  343.  
  344. if (length(sReturnString) > 0) then
  345. begin
  346. //Setup Message
  347. BroadCastMsg(sReturnString);
  348. end;
  349.  
  350. sReturnString := '';
  351. // cContext.Connection.IOHandler.WriteBufferClear;
  352. DrawScreen;
  353. SetPrompt();
  354. chInput := chr(0);
  355. end;
  356.  
  357. end;
  358.  
  359. //Clear Return String
  360. sReturnString := '';
  361.  
  362. end
  363.  
  364. //Else On Input Loop
  365. else
  366. begin
  367.  
  368. end;
  369.  
  370. end;
  371. end;
  372. ansi.CursorSavePos;
  373. CheckMsgs();
  374. ansi.CursorLastPos;
  375.  
  376.  
  377.  
  378.  
  379. //sRecvData := '';
  380.  
  381. {
  382. if (cMultiPlexerClient.IOHandler.CheckForDataOnSource(15)) then
  383. begin
  384. sRecvData := cMultiPlexerClient.IOHandler.ReadLn();
  385. self.LoadMsgs(sRecvData);
  386. self.PrintContent;
  387. end;
  388. }
  389.  
  390.  
  391.  
  392.  
  393. until (boolReturn = True);
  394.  
  395. end;
  396.  
  397. //Send Message Routine
  398. //This routine will take the text and write it to a file, to be sent by the multiplexer
  399.  
  400. procedure SendMsg(sMsg: string);
  401. begin
  402. cMultiPlexerClient.IOHandler.WriteLn(sMsg);
  403. end;
  404.  
  405. {
  406. class procedure MRCClient.SendMsg(sMsg: string);
  407. var
  408. sOutPath: string;
  409. sFormattedMsg: string;
  410. F: textfile;
  411. sFilename: string;
  412.  
  413. begin
  414. //Set Out Path To Write File
  415. sOutPath := programinfo.cbbsMRC.sMRCOutboundDir;
  416. if (DirectoryExists(sOutPath)) then
  417. begin
  418. //Set FileName:
  419. sFilename := 'outmess-' + random(9999999).ToString + '.mrc';
  420. AssignFile(F, sOutPath + sFilename);
  421. //Open For Writing
  422. rewrite(F);
  423. //Write To File
  424. writeln(F, sMsg);
  425. //Close File
  426. CloseFile(F);
  427. end;
  428. end;
  429. }
  430.  
  431. //Print Help
  432. procedure PrintHelp();
  433. begin
  434. AddContent('|11======= |15CyberBBS MRC Client Help |11=======');
  435. AddContent('');
  436. AddContent('|11[|14/?|11]|15...... Help With Functions');
  437. AddContent('|11[|14/cls|11]|15.... Clear Screen');
  438. AddContent('|11[|14/showmrcdir|11]|15.. Show MRC In Dir');
  439. AddContent('|11[|14/bbses|11]|15.. List Connected BBS Systems');
  440. AddContent('|11[|14/users|11]|15.. List Connected Users');
  441. AddContent('|11[|14/rooms|11]|15.. List Current Rooms On Server');
  442. AddContent('|11[|14/room|11]|15... List Current Room (Locally)');
  443. AddContent('|11[|14/quit|11]|15... Quit MRC Chat');
  444. AddContent('');
  445.  
  446. PrintContent;
  447.  
  448. //Return Prompt
  449. SetPrompt;
  450.  
  451. end;
  452.  
  453. //Print Content
  454. procedure PrintContent;
  455. var
  456. iLineCnt: integer;
  457. iAryCnt: integer;
  458. iWhereX: integer;
  459. iWhereY: integer;
  460.  
  461. begin
  462.  
  463. //Save Current Location
  464. //iWhereX := cyberio.GetX;
  465. //iWhereY := cyberio.GetY;
  466. ansi.CursorSavePos;
  467.  
  468. //Go To First Line To Print (Line 22)
  469. gotoxy(22, 1);
  470.  
  471. iLineCnt := 22;
  472. iAryCnt := 20;
  473.  
  474.  
  475. //Run Loop To Print All Lines
  476.  
  477. repeat
  478. ClearLine(iLineCnt);
  479. cyberio.PipeWriteString('|07' + ContentArray[iAryCnt]);
  480. iLineCnt := iLineCnt - 1;
  481. iAryCnt := iAryCnt - 1;
  482. gotoxy(iLineCnt, 1);
  483. until (iLineCnt = 1);
  484.  
  485. //Return To Start Position
  486. // gotoxy(iWhereY, iWhereX);
  487. ansi.CursorLastPos;
  488.  
  489. end;
  490.  
  491. //Shift Array Up And Add One Line To Last Area
  492. procedure ShiftArray;
  493. var
  494. iCnt: integer;
  495.  
  496. begin
  497. iCnt := 0;
  498. repeat
  499.  
  500. ContentArray[iCnt] := ContentArray[iCnt + 1];
  501.  
  502. iCnt := iCnt + 1;
  503.  
  504. until (iCnt = 20);
  505. ContentArray[20] := ' ';
  506. end;
  507.  
  508. //Add Content To Array
  509. procedure AddContent(sInput: string);
  510.  
  511. begin
  512. //Adjust Array
  513. ShiftArray;
  514.  
  515. ContentArray[20] := sInput;
  516.  
  517. end;
  518.  
  519. //Clear Line
  520. procedure ClearLine(iLine: integer);
  521. var
  522. iCnt: integer;
  523. begin
  524. iCnt := 1;
  525. gotoxy(iLine, 1);
  526. repeat
  527. cyberio.PipeWriteString(' ');
  528. Inc(iCnt);
  529. until (iCnt = 80);
  530. gotoxy(iLine, 1);
  531. end;
  532.  
  533. //Clear Screen & Array
  534. procedure ClearAll;
  535. var
  536. iCnt: integer;
  537.  
  538. begin
  539. iCnt := 0;
  540. repeat
  541. ContentArray[iCnt] := ' ';
  542. Inc(iCnt);
  543. until (iCnt = 20);
  544.  
  545. ansi.PipeClrScr;
  546. DrawScreen;
  547. // SetPrompt;
  548.  
  549. end;
  550.  
  551.  
  552. //Return, Clear Line, and Set Prompt
  553. procedure SetPrompt;
  554. begin
  555. ClearLine(24);
  556. gotoxy(24, 1);
  557. cyberio.PipeWriteString('|14[-> |15');
  558. gotoxy(24, 5);
  559. end;
  560.  
  561. //Send Message on MRC Chat (Direct - no file);
  562. procedure BroadCastMsg(sMsg: string);
  563. var
  564. sFormattedMsg: string;
  565.  
  566. begin
  567. //Add handle to msg
  568. sMsg := '|11<|14' + Sanitize(recCurrentUser.Handle) + '|11> |10' + sMsg;
  569.  
  570. //Format Msg
  571. sFormattedMsg := Sanitize(recCurrentUser.Handle) + '~' + Sanitize(programinfo.cbbsMRC.sBBSName) + '~' + Sanitize(sRoom) + '~~~~' + sMsg + '~';
  572. if (sFormattedMsg <> '') then
  573. begin
  574. SendMsg(sFormattedMsg); //Send Message Through Routine
  575. //cMRCMultiplexer.mrcMultiPlexer.SendMsg(sFormattedMsg); //Send Message with CRLF
  576. end;
  577. end;
  578.  
  579. procedure JoinMRC();
  580. var
  581. sFormattedMsg: string;
  582. sReturnMSg: string;
  583. sHandShake: string;
  584.  
  585. begin
  586. //Setup MSg
  587. sFormattedMsg := sanitize(userhandler.recCurrentUser.Handle) + '~' + sanitize(programinfo.cbbsMRC.sBBSName) + '~' + 'lobby' + '~NOTME~~~~';
  588.  
  589. //Send LogOff MSg
  590. //cMRCMultiplexer.mrcMultiPlexer.SendMsg(sFormattedMsg); //Send Message with CRLF
  591.  
  592. sHandShake := Sanitize(programinfo.cbbsMRC.sBBSName) + '~' + 'CyberBBS/Linux64/1.2.9';
  593. SendMsg(sHandShake);
  594. sleep(100);
  595. SendMsg(sFormattedMsg);
  596. sReturnMSg := cMultiPlexerClient.IOHandler.ReadLn();
  597.  
  598.  
  599. sleep(500);
  600. sRoom := 'lobby';
  601. AddContent('|10-Welcome to MRC Chat on CyberBBS!-');
  602. AddContent('Server Sent: ' + sReturnMSg);
  603. PrintContent;
  604. end;
  605.  
  606. //Quit
  607. procedure Quit();
  608. var
  609. sFormattedMsg: string;
  610.  
  611. begin
  612. //Setup MSg
  613. sFormattedMsg := userhandler.recCurrentUser.Handle + '~~~SERVER~~~LOGOFF~';
  614.  
  615. //Send LogOff MSg
  616. //cMRCMultiplexer.mrcMultiPlexer.SendMsg(sFormattedMsg); //Send Message with CRLF
  617. SendMsg(sFormattedMsg);
  618. sleep(250);
  619. cMultiPlexerClient.Disconnect;
  620. sleep(250);
  621. MainMenu.MainMenu();
  622. exit;
  623. end;
  624.  
  625. //Load Messages
  626. function LoadMsgs(sMsg: string): integer;
  627. var
  628. sFileDir: string;
  629. iCnt: integer;
  630. MsgList: TStringList;
  631. iMsgCnt: integer;
  632. F: TextFile;
  633. sData: string;
  634. MsgArray: TStringDynArray;
  635.  
  636. begin
  637. iCnt := 0;
  638. {
  639. sFileDir := csessions.cbbsSession.sMRC_In;
  640. MsgList := TStringList.Create();
  641. MsgList := fileutil.FindAllFiles(sFileDir, '*.mrc', False);
  642.  
  643. iMsgCnt := MsgList.Count;
  644.  
  645. if (MsgList.Count > 0) then
  646. begin
  647. repeat
  648. AssignFile(F, MsgList[iCnt]);
  649. reset(F);
  650. readln(F, sData);
  651. CloseFile(F);
  652.  
  653. }
  654.  
  655.  
  656.  
  657.  
  658. MsgArray := ParseMessage(sMsg);
  659.  
  660.  
  661.  
  662. //Check Msg For Auto-Response Messages
  663. if (MsgArray[6] = 'ping') then
  664. begin
  665. SendAlive(); //Send I Am Alive Message
  666. MsgArray[6] := '';
  667. end;
  668.  
  669. //Add Info If MsgArray Not Empty
  670. if (MsgArray[6] <> '') then
  671. begin
  672. Write('6: ' + MsgArray[6]);
  673. //Add Info From Array
  674. AddContent(MsgArray[6]);
  675.  
  676. end;
  677.  
  678.  
  679. //Send IAMHERE
  680. if (IAMHERECnt = 50) then
  681. begin
  682. SendIAMHERE();
  683. IAMHERECnt := 0;
  684. end
  685. else
  686. begin
  687. Inc(IAMHERECnt);
  688. end;
  689.  
  690. end;
  691.  
  692. //Parse Message Received
  693. function ParseMessage(sMessage: string): TStringDynArray;
  694. var
  695. ReturnString: TStringDynArray;
  696. begin
  697. ReturnString := strutils.SplitString(sMessage, '~');
  698. exit(ReturnString);
  699. end;
  700.  
  701. //Send IAMHere
  702. procedure SendIAMHERE();
  703. var
  704. sStringSend: string;
  705. begin
  706. sStringSend := userhandler.recCurrentUser.Handle + '~~~SERVER~~~IAMHERE~';
  707. // cMRCMultiplexer.mrcMultiPlexer.SendMsg(sStringSend); //Send Message with CRLF
  708. SendMsg(sStringSend);
  709. end;
  710.  
  711. //Send I AM Alive Response (Respond To Ping)
  712. procedure SENDALIVE();
  713. var
  714. sStringSend: string;
  715.  
  716. begin
  717. sStringSend := 'CLIENT~' + sanitize(programinfo.cbbsMRC.sBBSName) + '~~SERVER~ALL~~IMALIVE:' + sanitize(programinfo.cbbsMRC.sBBSName) + '~';
  718. SendMsg(sStringSend);
  719.  
  720. end;
  721.  
  722. //Replace Spaces with _
  723. function Sanitize(sStringGiven: string): string;
  724. var
  725. sReturnStringSani: string;
  726.  
  727. begin
  728. sReturnStringSani := strutils.StringReplace(sStringGiven, ' ', '_', [rfReplaceAll, rfIgnoreCase]);
  729. exit(sReturnStringSani);
  730. end;
  731.  
  732. //Get List Of Connected BBS Systems
  733. procedure cmd_BBSES();
  734. var
  735. sString: string;
  736. begin
  737. sString := '~~~SERVER~~~CONNECTED~';
  738. // cMRCMultiplexer.mrcMultiPlexer.SendMsg(sString); //Send Message with CRLF
  739. SendMsg(sString);
  740.  
  741.  
  742. //Print
  743. PrintContent();
  744.  
  745. //Return Prompt
  746. SetPrompt;
  747. end;
  748.  
  749. //Show Room (Local)
  750. procedure cmd_ROOM();
  751. begin
  752. AddContent('|15Current Room: |11' + sRoom);
  753. PrintContent;
  754. //Return Prompt
  755. SetPrompt;
  756. end;
  757.  
  758. //Request Users List & Print
  759. procedure cmd_USERS();
  760. var
  761. sString: string;
  762.  
  763. begin
  764. sString := '~~~SERVER~~~WHOON~';
  765. // cMRCMultiplexer.mrcMultiPlexer.SendMsg(sString); //Send Message with CRLF
  766. SendMsg(sString);
  767. //Return Prompt
  768. SetPrompt;
  769. end;
  770.  
  771. //Get A List of Rooms
  772. procedure cmd_ROOMLIST();
  773. var
  774. sString: string;
  775.  
  776. begin
  777. sString := '~~~SERVER~~~LIST~';
  778. //cMRCMultiplexer.mrcMultiPlexer.SendMsg(sString); //Send Message with CRLF
  779. SendMsg(sString);
  780. //Return Prompt
  781. SetPrompt;
  782. end;
  783.  
  784. //Show Current MRC Directory Being Used
  785. procedure cmd_SHOWMRCDIR();
  786. var
  787. sMRCDir: string;
  788.  
  789. begin
  790. //sMRCDir := csessions.cbbsSession.sMRC_In;
  791. // self.AddContent('|15Current MRC Dir: |11' + sMRCDir);
  792. // self.AddContent('');
  793. // self.PrintContent;
  794. // self.SetPrompt;
  795.  
  796. end;
  797.  
  798. function CheckDataFromClient(sMsgGiven: string): string;
  799. begin
  800. case sMsgGiven[1] of
  801. #32.. #126:
  802. begin
  803. exit(sMsgGiven);
  804. end;
  805.  
  806. else
  807. exit(chr(0));
  808. end;
  809. end;
  810.  
  811. {
  812. procedure CheckMsgs();
  813. var
  814. sMsg: string;
  815. sMsgChecked: string;
  816. boolRun: boolean;
  817.  
  818. begin
  819.  
  820. boolRun := True;
  821. sMsg := chr(0);
  822. Write('Start MSG');
  823.  
  824. repeat
  825. sMsg := chr(0);
  826. if (cMultiPlexerClient.IOHandler.CheckForDataOnSource(10)) then
  827. begin
  828. sMsg := cMultiPlexerClient.IOHandler.ReadLn();
  829. sMsgChecked := CheckDataFromClient(sMsg);
  830. if (sMsgChecked <> chr(0)) then
  831. begin
  832. SendIAMHERE();
  833. LoadMsgs(sMsg);
  834. PrintContent;
  835. end;
  836. end
  837. else
  838. sMsg := chr(0);
  839.  
  840.  
  841. Write('MSg: ' + sMsg);
  842.  
  843.  
  844. until (sMsg = chr(0));
  845.  
  846. end;
  847. }
  848.  
  849. procedure CheckMsgs();
  850. var
  851. sMsg: string;
  852. List : TStringList;
  853. iCnt : integer;
  854. begin
  855.  
  856. {
  857. sMsg := '';
  858. Write('Start MSG');
  859. repeat
  860. if cMultiPlexerClient.IOHandler.InputBufferIsEmpty then
  861. begin
  862. cMultiPlexerClient.IOHandler.CheckForDataOnSource(250);
  863. cMultiPlexerClient.IOHandler.CheckForDisconnect;
  864. if cMultiPlexerClient.IOHandler.InputBufferIsEmpty then Break;
  865. end;
  866. // sMsg := cMultiPlexerClient.IOHandler.ReadLn();
  867.  
  868. Write('MSg: ' + sMsg);
  869. LoadMsgs(sMsg);
  870. PrintContent();
  871. sMsg := '';
  872. until False;
  873. }
  874. iCnt := 0;
  875.  
  876. //list := TStringList.Create;
  877. list := Msgs.lock;
  878. try
  879. repeat
  880. write(list.Strings[iCnt]);
  881. LoadMsgs(list.Strings[iCnt]);
  882. PrintContent;
  883. iCnt := iCnt + 1;
  884. until (iCnt = List.Count);
  885. list.clear;
  886. finally
  887. Msgs.unlock;
  888.  
  889.  
  890. end;
  891.  
  892.  
  893.  
  894. end;
  895.  
  896. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement