//--------------------------------------------------------------------- public Task SetPlayerInfo(PlayerInfo playerInfo) { PlayerInfo = playerInfo; IMContext.Instance.Mongo.UpsertAsync<PlayerInfo>( e => e.Id == playerInfo.Id, DbCollectPlayerInfo, playerInfo); return TaskDone.Done; }
//--------------------------------------------------------------------- // 通知添加好友请求(通知) public override void onAddFriendRequestNotify(PlayerInfo request_player) { }
//--------------------------------------------------------------------- // App->Cell Task IGrainIMTestAppPlayer.UpdateInfo(PlayerInfo info) { Logger.Info("UpdateInfo() GrainId={0}", GrainKey); return TaskDone.Done; }
//--------------------------------------------------------------------- Task IGrainAppProxyService.UpdatePlayerInfo(PlayerInfo playerInfo) { string grain_key = string.Format("{0}_{1}", AppId, playerInfo.Id); var grain_playerapp = GrainFactory.GetGrain<IGrainPlayer>(grain_key); return grain_playerapp.UpdateInfo(playerInfo); }
//--------------------------------------------------------------------- // App->Cell Task IGrainPlayer.UpdateInfo(PlayerInfo info) { Logger.Info("UpdateInfo() GrainId={0}", GrainKey); // 更新缓存 PlayerCache.SetPlayerInfo(info); // 向好友广播本人资料更新 var grainPlayerBroadcast = GrainFactory.GetGrain<IGrainPlayerBroadcast>(GrainKey); grainPlayerBroadcast.BroadcastPlayerInfoUpdate(info); // 通知Client if (!GrainClientKey.Equals(Guid.Empty)) { var data = EbTool.protobufSerialize<PlayerInfo>(MemoryStream, info); // 推送给Client PlayerNotify player_notify; player_notify.id = PlayerNotifyId.UpdatePlayerInfoNotify; player_notify.data = data; ((IGrainPlayer)this).ClientNotify(player_notify); } return TaskDone.Done; }
//--------------------------------------------------------------------- // 好友信息更新,GrainPlayerBroadcast->GrainPlayer Task IGrainPlayer.UpdateFriendInfo(PlayerInfo info) { return TaskDone.Done; }
//--------------------------------------------------------------------- // 通知添加好友请求(通知) public abstract void onAddFriendRequestNotify(PlayerInfo request_player);
//--------------------------------------------------------------------- // 本人信息更新广播到好友列表 Task IGrainPlayerBroadcast.BroadcastPlayerInfoUpdate(PlayerInfo playerInfo) { var data = EbTool.protobufSerialize<PlayerInfo>(MemoryStream, playerInfo); return Broadcast(StreamId.PlayerInfoUpdate, data); }