/// <summary>
 /// Subscribes a client to a tile
 /// </summary>
 public static void SubscribeTile(DTSession session, DynamicTileTarget target, int token)
 {
     lock (subscriptions)
     {
         subscriptions.Add(new TileSubscription
         {
             session = session,
             target  = target,
             token   = token
         });
     }
 }
示例#2
0
        public static async Task AcceptV1Request(Microsoft.AspNetCore.Http.HttpContext e)
        {
            //First, authenticate this user
            DTSession session = await DTSession.AuthenticateSession(e.Request.Query["access_token"]);

            if (session == null)
            {
                //Failed to authenticate
                e.Response.StatusCode = 401;
                return;
            }

            //Accept the socket
            var socket = await e.WebSockets.AcceptWebSocketAsync();

            //Set up the client
            await session.Run(socket);
        }
 /// <summary>
 /// Unsubscribes a client from a tile
 /// </summary>
 /// <param name="session"></param>
 /// <param name="target"></param>
 public static void UnsubscribeTile(DTSession session, int token)
 {
     lock (subscriptions)
         subscriptions.RemoveAll(x => x.token == token && x.session == session);
 }