let user_tbl = (ref [] : user list ref)
(* session table: (user id, session id), matita status *)
-type session = (string * session_id) * MatitaEngine.status
+type session = session_id * (MatitaEngine.status * MatitaEngine.status list)
let session_tbl = (ref [] : session list ref)
let lookup_user uid = List.assoc uid !user_tbl
-let create_session uid status =
+let create_session uid =
+ let status = new MatitaEngine.status (Some uid) "cic:/matita" in
+ let history = [status] in
let pw,sid = List.assoc uid !user_tbl in
let clean_utbl = List.remove_assoc uid !user_tbl in
let new_session = Uuidm.create `V4 in
user_tbl := (uid,(pw,Some new_session))::clean_utbl;
let clean_stbl = match sid with
| Some sid' ->
- List.remove_assoc (uid,sid') !session_tbl
+ List.remove_assoc sid' !session_tbl
| _ -> !session_tbl
- in session_tbl := ((uid,new_session),status)::clean_stbl
+ in
+ session_tbl := (new_session,(status,history))::clean_stbl;
+ new_session
;;
+let get_status sid = fst (List.assoc sid !session_tbl)
+
+let get_history sid = snd (List.assoc sid !session_tbl)
+
+let set_status sid st =
+ let oldst, hist = List.assoc sid !session_tbl in
+ session_tbl := (sid,(st,hist))::(List.remove_assoc sid !session_tbl)
+
+let set_history sid hist =
+ let st, oldhist = List.assoc sid !session_tbl in
+ session_tbl := (sid,(st,hist))::(List.remove_assoc sid !session_tbl)
+
let logout_user uid =
match List.assoc uid !user_tbl with
| _,None -> ()
| pw, Some sid ->
user_tbl := (uid,(pw,None))::List.remove_assoc uid !user_tbl;
- session_tbl := List.remove_assoc (uid,sid) !session_tbl
+ session_tbl := List.remove_assoc sid !session_tbl
;;
let remove_user uid =