コード例 #1
0
 public IWebMessage Post([FromBody] NewMessage msg)
 {
     msg.UserId = _auth.Authenticate(HttpContext).Id;
     if (ModelState.IsValid)
     {
         //Message object is good:
         IWebMessage message = _manager.Create(msg);
         if (message != null)
         {
             return(message);
         }
     }
     throw new Exception("Invalid Message Data - ARGH");
 }
コード例 #2
0
        public override async void OnConnected(WebSocket socket, HttpContext context)
        {
            var user = _am.Authenticate(context);

            if (user == null)
            {
                socket.Abort(); return;
            }
            base.OnConnected(socket, context);
            var socketUser = new SocketUser(user, _cm, socket);

            AllConnectedUsers.TryAdd(socket, socketUser);
            foreach (var c in socketUser.SubscribedChannels)
            {
                Channels.TryGetValue(c.Id, out SocketChannel channel);
                channel.JoinChannel(socketUser);
            }

            var socketId = WSManager.GetId(socket);

            await SendMessageToAllAsync("{ \"type\": \"USERCONNECTED\", \"message\":\"" + user.Email + " is now connected\"}");
        }
コード例 #3
0
        public IActionResult UserDetails()
        {
            var x = _manager.Authenticate(HttpContext);

            return(View(x));
        }
コード例 #4
0
        public IEnumerable <IChannel> Get()
        {
            var userId = _am.Authenticate(HttpContext).Id;

            return(_cm.GetSubscribedChannels(userId));
        }