CSharpRTMP.Core.Protocols.Rtmp.SO.Set C# (CSharp) Method

Set() public method

public Set ( string key, Variant value, BaseProtocol pFrom = null ) : Variant
key string
value Variant
pFrom BaseProtocol
return Variant
        public Variant Set(string key, Variant value, BaseProtocol pFrom = null)
        {
            if (value == null || value == VariantType.Null)
            {
                UnSet(key);
                return value;
            }
            if (!_versionIncremented)
            {
                Version++;
                _versionIncremented = true;
            }
            Payload[key] = value;
            var updateDirtyInfo = new DirtyInfo {PropertyName = key, Type = Defines.SOT_SC_UPDATE_DATA};
            Synchronization?.Invoke(updateDirtyInfo);
#if PARALLEL
            _dirtyPropsByProtocol.AsParallel().ForAll(x => x.Value.Add(new DirtyInfo { PropertyName = key, Type =x.Key == protocolId ? Defines.SOT_SC_UPDATE_DATACK : Defines.SOT_SC_UPDATE_DATA} ));
#else

            foreach (var registeredProtocol in _dirtyPropsByProtocol)
            {
                if (registeredProtocol.Key == pFrom)
                {
                    if (pFrom is BaseClusterProtocol)continue;
                    registeredProtocol.Value.Add(new DirtyInfo
                    {
                        PropertyName = key,
                        Type = Defines.SOT_SC_UPDATE_DATA_ACK
                    });
                }
                else
                {
                    registeredProtocol.Value.Add(updateDirtyInfo);
                }
            }
#endif
            return Payload[key];
        }

Usage Example

Example #1
0
        private bool ProcessSharedObjectPrimitive(BaseRTMPProtocol pFrom, SO pSO, string name, Variant request,
                                                  int primitiveId)
        {
            var primitive = request[Defines.RM_SHAREDOBJECT, Defines.RM_SHAREDOBJECT_PRIMITIVES][primitiveId];

            switch ((byte)primitive[Defines.RM_SHAREDOBJECTPRIMITIVE_TYPE])
            {
            case Defines.SOT_CS_CONNECT:
                pSO.RegisterProtocol(pFrom);
                return(true);

            case Defines.SOT_CS_DISCONNECT:
                UnRegisterProtocol(pFrom);
                return(true);

            case Defines.SOT_CSC_DELETE_DATA:
                pSO.UnSet(primitive[Defines.RM_SHAREDOBJECTPRIMITIVE_PAYLOAD], pFrom);
                return(true);

            case Defines.SOT_CS_SET_ATTRIBUTE:
                if (pSO == null)
                {
                    Logger.FATAL("SO is null");
                    return(false);
                }
                foreach (KeyValuePair <string, Variant> item in primitive[Defines.RM_SHAREDOBJECTPRIMITIVE_PAYLOAD])
                {
                    pSO.Set(item.Key, item.Value.Clone(), pFrom);
                }
                return(true);

            case Defines.SOT_BW_SEND_MESSAGE:
                pSO?.Send(primitive, pFrom);
                return(true);

            default:
                Logger.FATAL("SO primitive not allowed here");
                return(false);
            }
        }
All Usage Examples Of CSharpRTMP.Core.Protocols.Rtmp.SO::Set