Example #1
0
        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();
            }
        }
Example #2
0
        /// <summary>
        /// Set Or Update Room Property  ,You Can Add or Edit A Property
        /// </summary>
        /// <param name="property">The Property You Want To Add or Edit</param>
        public static void SetOrUpdateRoomProperty(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.ApplyRoomProperty(property);

            var propertyData = new PropertyData(property.PropertyName, property.PropertyData);

            SenderUtil.NetworkProperty(propertyData, PropertyAction.SetOrUpdateRoomProperty);
        }