public void RemoveSession(DataSession s) { sessions_.Remove(s.Name); }
private void MonitorListener(object listobj) { DataListener listener = listobj as DataListener; while (running_) { string resp = listener.WaitForData(); if (resp.StartsWith(startkeyword)) { string name; string [] cols; int id; DataSession session; if (!ParseStartLine(resp, out name, out id, out cols)) { return; } lock (session_lock_) { if (sessions_.ContainsKey(name)) { session = sessions_[name]; if (!session.Reset(id, cols)) { session = null; } } else { session = new DataSession(name, id, cols); sessions_[name] = session; } } if (session != null) { OnDataSessionStarted(new DataManagerEventArgs(session)); } } else if (resp.StartsWith(datakeyword)) { int id; int col; int row; double value; DataSession session = null; if (!ParseDataLine(resp, out id, out row, out col, out value)) { return; } lock (session_lock_) { session = GetSessionByID(id); } if (session != null) { session.AddData(row, col, value); } } else if (resp.StartsWith(endkeyword)) { resp = resp.Substring(endkeyword.Length); resp = resp.Substring(0, resp.Length - 1); int id; if (!Int32.TryParse(resp, out id)) { return; } DataSession session = null; lock (session_lock_) { session = GetSessionByID(id); if (session != null) { session.Finished = true; } } if (session != null) { OnDataSessionFinished(new DataManagerEventArgs(session)); } } else { // // We got bad data, not understood. Ignore for now. In the future report // it somehow // } } }
public DataManagerEventArgs(DataSession session) { Session = session; }