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); }
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; } }
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); }
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); }); }