コード例 #1
0
 public async Task<bool> RegistDeviceTokenAsync(BahamutPublishModel msgModel)
 {
     dynamic msg = Newtonsoft.Json.JsonConvert.DeserializeObject(msgModel.Info);
     var dt = new DeviceToken
     {
         Token = msg.DeviceToken,
         Type = msg.DeviceType
     };
     string accountid = msg.AccountId;
     LogManager.GetLogger("Info").Info("Regist {0} Device Of Account:{1}",dt.Type, accountid);
     return await ChicagoServer.BahamutPubSubService.RegistUserDeviceAsync(msgModel.ToUser, dt, DeviceTokenExpireTime);
 }
コード例 #2
0
        public async Task<bool> UpdateUserDeviceTokenAynce(BahamutAppUser appUser, DeviceToken deviceToken)
        {
            try
            {
                var suc = await ChicagoServer.BahamutPubSubService.RegistUserDeviceAsync(appUser.UserData.UserId, appUser.DeviceToken, DeviceTokenExpireTime);
                if (suc)
                {
                    appUser.DeviceToken = deviceToken;
                }
                return suc;
            }
            catch (Exception)
            {
                LogManager.GetLogger("Warn").Info("Regist Device Token Error:{0}", appUser.UserData.UserId);
                return false;
            }

        }
コード例 #3
0
 public async Task<bool> RegistUserDeviceAsync(string userId, DeviceToken deviceToken, TimeSpan expireTime)
 {
     var dt = JsonConvert.SerializeObject(deviceToken, Formatting.None);
     return await pubsubRedis.GetDatabase().StringSetAsync(userId, dt, expireTime);
 }
コード例 #4
0
        public void RegistDeviceToken(ICSharpServerSession session, dynamic msg)
        {
            var appUser = session.User as BahamutAppUser;

            var dt = new DeviceToken
            {
                Token = msg.DeviceToken,
                Type = msg.DeviceType
            };
            Task.Run(async () =>
            {
                await userManager.UpdateUserDeviceTokenAynce(appUser, dt);
            });
        }