text
stringlengths
0
234
while Active_Clients.Has_Element(C) loop
EP_Image := ASU.To_Unbounded_String(LLU.Image(Active_Clients.Element
(C).Value.Client_EP));
Ada.Text_IO.Put_Line (ASU.To_String(Active_Clients.Element(C).Key) &
" " &
ASU.To_String(Format_EP(EP_Image)) & " " &
Time_Image(Active_Clients.Element(C).Value.Time));
Active_Clients.Next(C);
end loop;
ATI.New_Line;
end Print_Active_Map;
procedure Print_Old_Map is
C: Old_Clients.Cursor := Old_Clients.First(Old_Map);
begin
Ada.Text_IO.Put_Line ("OLD CLIENTS");
Ada.Text_IO.Put_Line ("===========");
while Old_Clients.Has_Element(C) loop
Ada.Text_IO.Put_Line (ASU.To_String(Old_Clients.Element(C).Key) &
": " & Time_Image(Old_Clients.Element(C).Value));
Old_Clients.Next(C);
end loop;
ATI.New_Line;
end Print_Old_Map;
function Client_To_Ban (Active_Map: Active_Clients.Map) return ASU.Unbounded_String is
C: Active_Clients.Cursor := Active_Clients.First(Active_Map);
Min_Time: Ada.Calendar.Time;
Nick: ASU.Unbounded_String;
begin
Min_Time := Active_Clients.Element(C).Value.Time;
Nick := Active_Clients.Element(C).Key;
while Active_Clients.Has_Element(C) loop
if Active_Clients.Element(C).Value.Time < Min_Time then
Nick := Active_Clients.Element(C).Key;
end if;
Active_Clients.Next(C);
end loop;
return Nick;
end Client_To_Ban;
procedure Server_To_All (Comment: ASU.Unbounded_String;
O_Buffer: access LLU.Buffer_Type) is
C: Active_Clients.Cursor := Active_Clients.First(Active_Map);
Nick: ASU.Unbounded_String := ASU.To_Unbounded_String("Server");
begin
while Active_Clients.Has_Element(C) loop
CM.Server_Message (Active_Clients.Element(C).Value.Client_EP,
Nick,Comment,O_Buffer);
Active_Clients.Next(C);
end loop;
end Server_To_All;
procedure Case_Init (I_Buffer: access LLU.Buffer_Type;
O_Buffer: access LLU.Buffer_Type) is
Client_EP_Receive: LLU.End_Point_Type;
Client_EP_Handler: LLU.End_Point_Type;
Nick: ASU.Unbounded_String;
Ban_Nick: ASU.Unbounded_String;
Comment: ASU.Unbounded_String;
Logout_Time: Ada.Calendar.Time;
Client_Data: Data;
Accepted: Boolean;
Success: Boolean;
begin
Client_EP_Receive := LLU.End_Point_Type'Input (I_Buffer);
Client_EP_Handler := LLU.End_Point_Type'Input (I_Buffer);
Nick := ASU.Unbounded_String'Input (I_Buffer);
Active_Clients.Get(Active_Map,Nick,Client_Data,Success);
if Success then
Accepted := False;
ATI.Put_Line("INIT received from " & ASU.To_String(Nick)
& ": IGNORED. nick already used");
else
ATI.Put_Line("INIT received from " & ASU.To_String(Nick)
& ": ACCEPTED");
begin
Accepted := True;
Client_Data.Client_EP := Client_EP_Handler;
Client_Data.Time := Ada.Calendar.Clock;
Active_Clients.Put (Active_Map,Nick,Client_Data);