コード例 #1
0
        public ActionResult Auth(string channel_name, string socket_id)
        {
            var applicationId = ConfigurationManager.AppSettings["pusher_app_id"];
            var applicationKey = ConfigurationManager.AppSettings["pusher_key"];
            var applicationSecret = ConfigurationManager.AppSettings["pusher_secret"];

            //var channelData = new PresenceChannelData()
            //{
            //    user_id = Guid.NewGuid().ToString()
            //};
            var channelData = new PresenceChannelData();
            if (User.Identity.IsAuthenticated)
            {
                channelData.user_id = User.Identity.Name;
            }
            else
            {
                channelData.user_id = Guid.NewGuid().ToString();
            }
            channelData.user_info = new PusherUserInfo();

            var provider = new PusherProvider(applicationId, applicationKey, applicationSecret);
            string authJson = provider.Authenticate(channel_name, socket_id, channelData);

            return new ContentResult { Content = authJson, ContentType = "application/json" };
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            SetupDefaultProvider(context);

            var provider = new PusherProvider(applicationId, applicationKey, applicationSecret);
            string authJson = provider.Authenticate(socketID, channelName);

            context.Response.Write(authJson);
        }
コード例 #3
0
        public ActionResult Auth(string channel_name, string socket_id)
        {
            var channelData = new PresenceChannelData();
            if (User.Identity.IsAuthenticated)
            {
                channelData.user_id = User.Identity.Name;
            }
            else
            {
                channelData.user_id = GetUniqueUserId();
            }
            channelData.user_info = GetUserInfo();

            var provider = new PusherProvider(applicationId, applicationKey, applicationSecret);
            string authJson = provider.Authenticate(channel_name, socket_id, channelData);

            return new ContentResult { Content = authJson, ContentType = "application/json" };
        }