private static void ApplyProperty(byte action, byte[] data, string ownerId, IPropertyHandler handler) { var actions = (PropertyAction)action; var property = new PropertyData(); GsSerializer.Object.CallReadStream(property, data); switch (actions) { case PropertyAction.SetOrUpdateMemberProperty: handler.ApplyMemberProperty(ownerId, new Property(property.Name, property.Data)); GsLiveRealtime.Callbacks.OnPropertyEvent?.Invoke(null, new OnPropertyEvent(property.Name, ownerId, actions, property.Data)); break; case PropertyAction.RemoveMemberProperty: handler.RemoveMemberProperty(ownerId, property.Name); GsLiveRealtime.Callbacks.OnPropertyEvent?.Invoke(null, new OnPropertyEvent(property.Name, ownerId, actions)); break; case PropertyAction.SetOrUpdateRoomProperty: handler.ApplyRoomProperty(new Property(property.Name, property.Data)); GsLiveRealtime.Callbacks.OnPropertyEvent?.Invoke(null, new OnPropertyEvent(property.Name, ownerId, actions, property.Data)); break; case PropertyAction.RemoveRoomProperty: handler.RemoveRoomProperty(property.Name); GsLiveRealtime.Callbacks.OnPropertyEvent?.Invoke(null, new OnPropertyEvent(property.Name, ownerId, actions)); break; default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Set Or Update Member Property ,You Can Add or Edit A Member Property /// </summary> /// <param name="property">The Property You Want To Add or Edit</param> public static void SetOrUpdateMemberProperty(Property property) { if (!IsAvailable) { throw new GameServiceException("GsLiveRealtime is Not Available"); } if (!FiroozehGameService.Core.GameService.GSLive.IsRealTimeAvailable()) { throw new GameServiceException("RealTime is Not Available"); } _propertyHandler.ApplyMemberProperty(CurrentPlayerMemberId, property); var propertyData = new PropertyData(property.PropertyName, property.PropertyData); SenderUtil.NetworkProperty(propertyData, PropertyAction.SetOrUpdateMemberProperty); }