Now uses DataWaiting to help prevent named pipe blocking

This commit is contained in:
mysticbbs 2012-09-23 15:09:39 -04:00
parent eec7002fe0
commit 379523d459
2 changed files with 78 additions and 24 deletions

View File

@ -396,13 +396,6 @@ Var
End;
Begin
GetChatRecord(Node, Chat);
If Not Chat.Active Then Begin
ShowMsgBox(0, 'Node ' + strI2S(Node) + ' is not in use');
Exit;
End;
ShowMsgBox (3, 'Requesting snoop session for node ' + strI2S(Node));
SendNodeMessage(Node, 11);
@ -427,12 +420,14 @@ Begin
Update := TimerSet(UpdateNode);
While Pipe.Connected Do Begin
If Pipe.DataWaiting Then Begin
Pipe.ReadFromPipe(Buffer, SizeOf(Buffer), BufRead);
If BufRead = 0 Then
If BufRead <= 0 Then
WaitMS(200)
Else
Term.ProcessBuf(Buffer, BufRead);
End;
If Keyboard.KeyPressed Then
Case Keyboard.ReadKey of
@ -444,6 +439,7 @@ Begin
#45 : Break;
#46 : DoUserChat(Node);
End;
#27 : Break;
End;
If TimerUp(Update) Then Begin
@ -715,14 +711,18 @@ Begin
End;
End;
#13 : Begin
GetChatRecord(NodeInfo[CurNode]^.Node, Chat);
If Not Chat.Active Then Begin
ShowMsgBox(0, 'Node ' + strI2S(NodeInfo[CurNode]^.Node) + ' is not in use');
Continue;
End;
Case GetCommandOption(8, 'S-Snoop|C-User Chat|K-Kick User|G-Kill Ghost|') of
'S' : Begin
SnoopNode(NodeInfo[CurNode]^.Node);
FullReDraw;
End;
#32 : Begin
Terminal;
FullReDraw;
End;
#27 : Break;
'G' : If ShowMsgBox(1, 'Kill Ghost on Node ' + strI2S(NodeInfo[CurNode]^.Node)) Then Begin
FileErase(Config.DataPath + 'chat' + strI2S(NodeInfo[CurNode]^.Node) + '.dat');
@ -731,6 +731,19 @@ Begin
NodeTimer := TimerSet(UpdateNode);
End;
'K' : If ShowMsgBox(1, 'Kick this user?') Then
SendNodeMessage(NodeInfo[CurNode]^.Node, 13);
'C' : Begin
DoUserChat(NodeInfo[CurNode]^.Node);
FullReDraw;
End;
End;
End;
#32 : Begin
Terminal;
FullReDraw;
End;
#27 : Break;
End;
If TimerUp(NodeTimer) Then Begin

View File

@ -10,10 +10,12 @@ Uses
m_Output,
m_Term_Ansi,
m_MenuBox,
m_MenuForm,
m_MenuInput;
Function ShowMsgBox (BoxType: Byte; Str: String) : Boolean;
Function GetStr (Header, Text, Def: String; Len, MaxLen: Byte) : String;
Function GetCommandOption (StartY: Byte; CmdStr: String) : Char;
{$I RECORDS.PAS}
@ -153,4 +155,43 @@ Begin
Result := Str;
End;
Function GetCommandOption (StartY: Byte; CmdStr: String) : Char;
Var
Box : TMenuBox;
Form : TMenuForm;
Count : Byte;
Cmds : Byte;
CmdData : Array[1..10] of Record
Key : Char;
Desc : String[18];
End;
Begin
Cmds := 0;
While Pos('|', CmdStr) > 0 Do Begin
Inc (Cmds);
CmdData[Cmds].Key := CmdStr[1];
CmdData[Cmds].Desc := Copy(CmdStr, 3, Pos('|', CmdStr) - 3);
Delete (CmdStr, 1, Pos('|', Cmdstr));
End;
Box := TMenuBox.Create(Screen);
Form := TMenuForm.Create(Screen);
Form.HelpSize := 0;
Box.Open (30, StartY, 51, StartY + Cmds + 1);
For Count := 1 to Cmds Do
Form.AddNone (CmdData[Count].Key, ' ' + CmdData[Count].Key + ' ' + CmdData[Count].Desc, 31, StartY + Count, 20, '');
Result := Form.Execute;
Form.Free;
Box.Close;
Box.Free;
End;
End.