let remove_state_rcv_stack (name_in_session : string) (state : string) : unit =
let remove_message name_in_session message =
let res = ref false in
let message_list = Hashtbl.find_all message_stack name_in_session in
let rec aux l buff =
match l with [] -> (List.iter (fun t -> (Hashtbl.add message_stack name_in_session t)) buff)
|(x::ls) -> ( Hashtbl.remove message_stack name_in_session;
if (x=message)
then(res:=true ; aux ls buff)
else(aux ls (x::buff)));
in
aux message_list [];
if(!res) then
( if(List.mem (name_in_session,message) (!add_on_stack))
then add_on_stack:=remove (name_in_session,message) (!add_on_stack)
else remove_of_stack:= (name_in_session,message)::(!remove_of_stack)
);
in
(Hashtbl.iter
(fun n message -> if((name_in_session,state,"_rcv_stack")=n) then (remove_message n message))
message_stack)