//--------------------------------------------------------------------- public Task SetPlayerRealtimeInfo(PlayerRealtimeInfo playerRealtimeInfo) { PlayerRealtimeInfo = playerRealtimeInfo; IMContext.Instance.Mongo.UpsertAsync<PlayerRealtimeInfo>( e => e.Id == playerRealtimeInfo.Id, DbCollectPlayerRealtimeInfo, playerRealtimeInfo); return TaskDone.Done; }
//--------------------------------------------------------------------- // App->Cell Task IGrainIMTestAppPlayer.UpdateRealtimeInfo(PlayerRealtimeInfo info) { Logger.Info("UpdateRealtimeInfo() GrainId={0}", GrainKey); return TaskDone.Done; }
//--------------------------------------------------------------------- Task IGrainAppProxyService.UpdatePlayerRealtimeInfo(PlayerRealtimeInfo playerRealtimeInfo) { string grain_key = string.Format("{0}_{1}", AppId, playerRealtimeInfo.Id); var grain_playerapp = GrainFactory.GetGrain<IGrainPlayer>(grain_key); return grain_playerapp.UpdateRealtimeInfo(playerRealtimeInfo); }
//--------------------------------------------------------------------- // App->Cell Task IGrainPlayer.UpdateRealtimeInfo(PlayerRealtimeInfo info) { Logger.Info("UpdateRealtimeInfo() GrainId={0}", GrainKey); // 更新缓存 PlayerCache.SetPlayerRealtimeInfo(info); // 向好友广播本人实时资料更新 var grainPlayerBroadcast = GrainFactory.GetGrain<IGrainPlayerBroadcast>(GrainKey); grainPlayerBroadcast.BroadcastPlayerRealtimeInfoUpdate(info); // 通知Client if (!GrainClientKey.Equals(Guid.Empty)) { var data = EbTool.protobufSerialize<PlayerRealtimeInfo>(MemoryStream, info); // 推送给Client PlayerNotify player_notify; player_notify.id = PlayerNotifyId.UpdatePlayerRealtimeInfoNotify; player_notify.data = data; ((IGrainPlayer)this).ClientNotify(player_notify); } return TaskDone.Done; }
//--------------------------------------------------------------------- // 好友实时信息更新,GrainPlayerBroadcast->GrainPlayer Task IGrainPlayer.UpdateFriendRealtimeInfo(PlayerRealtimeInfo info) { return TaskDone.Done; }
//--------------------------------------------------------------------- // 本人实时信息更新广播到好友列表 Task IGrainPlayerBroadcast.BroadcastPlayerRealtimeInfoUpdate(PlayerRealtimeInfo playerRealtimeInfo) { var data = EbTool.protobufSerialize<PlayerRealtimeInfo>(MemoryStream, playerRealtimeInfo); return Broadcast(StreamId.PlayerRealtimeInfoUpdate, data); }