SessionService
using Skipcheck.Tm1.Client.Services; Server sessions: every session logged in to the server (/Sessions), this one's
(ActiveSession), their users and threads, and closing another session.
To close this client's own session, close the Tm1Session or Tm1Client:
it sends ActiveSession/tm1.Close, and knows not to log in again. A closed
session stays listed in Sessions for a few seconds (5 to 9 in TM1 11.8).
List who's logged in, expanding each session's user:
// Every session on the server, with its user's name and its label
return tm1
.Sessions.ListAsync(
ODataQuery.None().Select(Session.Fields.Id, Session.Fields.Context).Expand(Session.Fields.User, user => user.Select(User.Fields.Name))
)
.Select(session => $"{session.Id} {session.User?.Name} {session.Context}");
Close other clients' sessions by their label, sparing this one:
// Close the sessions labelled "Nightly load", except this client's own
var own = (await tm1.Sessions.ActiveSessionAsync(ODataQuery.None().Select(Session.Fields.Id))).Id;
var labelled = ODataQuery.None().Select(Session.Fields.Id).Filter(Session.Fields.Context.Eq("Nightly load"));
await foreach (var session in tm1.Sessions.ListAsync(labelled))
{
if (session.Id is { } id && id != own)
{
await tm1.Sessions.CloseAsync(id);
}
}
Members
SessionService constructor | A service that sends its requests through session. |
ListAsync | GET Sessions, streamed. |
GetAsync | GET Sessions(id), or a Tm1NotFoundException if there's none. |
ActiveSessionAsync | This client's own session on the server. |
UserAsync | GET Sessions(id)/User. |
ThreadsAsync | GET Sessions(id)/Threads, streamed. |
CloseAsync | Ends another session; its client must log in again. |
SessionService
constructorSessionService(Tm1Session session)A service that sends its requests through session.
ListAsync
IAsyncEnumerable<ServerSession> ListAsync(ODataQuery? query = null, CancellationToken cancellationToken = default)GET Sessions, streamed: every session on the server, for an admin. Expands
User and Threads.
TM1 REST EntitySet Sessions
GetAsync
Task<ServerSession> GetAsync(long id, ODataQuery? query = null, CancellationToken cancellationToken = default)GET Sessions(id), or a Tm1NotFoundException if there's none.
TM1 REST EntitySet Sessions
ActiveSessionAsync
Task<ServerSession> ActiveSessionAsync(ODataQuery? query = null, CancellationToken cancellationToken = default)GET ActiveSession: this client's own session on the server.
TM1 REST Singleton ActiveSession
UserAsync
Task<User> UserAsync(long id, ODataQuery? query = null, CancellationToken cancellationToken = default)GET Sessions(id)/User.
TM1 REST Navigation Session/User
ThreadsAsync
IAsyncEnumerable<ServerThread> ThreadsAsync(long id, ODataQuery? query = null, CancellationToken cancellationToken = default)GET Sessions(id)/Threads, streamed: what the session is running now.
TM1 REST Navigation Session/Threads
CloseAsync
Task CloseAsync(long id, CancellationToken cancellationToken = default)tm1.Close: ends another session; its client must log in again. Needs schema 10.2.2.5.
TM1 REST Action Session/Close