Exemplo n.º 1
0
        public void SessionAbortedByPartner(
            BOOLEAN isInbound,
            NativeReliableMessaging.IFabricReliableSessionPartitionIdentity partitionId,
            NativeReliableMessaging.IFabricReliableSession session)
        {
            var closingSession = ReliableMessagingSession.FromNative(session);

            var nativeSvcName = partitionId.getServiceName();
            var svcInstance   = NativeTypes.FromNativeUri(nativeSvcName);

            var partitionKeyType = partitionId.getPartitionKeyType();
            var partitionKey     = partitionId.getPartitionKey();

            if (partitionKeyType == NativeTypes.FABRIC_PARTITION_KEY_TYPE.FABRIC_PARTITION_KEY_TYPE_NONE)
            {
                this.managedCallback.SessionAbortedByPartner(NativeTypes.FromBOOLEAN(isInbound), svcInstance, closingSession);
            }
            else if (partitionKeyType == NativeTypes.FABRIC_PARTITION_KEY_TYPE.FABRIC_PARTITION_KEY_TYPE_INT64)
            {
                var int64KeyRange = IntegerPartitionKeyRangeFactory.FromNative(partitionKey);
                this.managedCallback.SessionAbortedByPartner(NativeTypes.FromBOOLEAN(isInbound), svcInstance, int64KeyRange, closingSession);
            }
            else if (partitionKeyType == NativeTypes.FABRIC_PARTITION_KEY_TYPE.FABRIC_PARTITION_KEY_TYPE_STRING)
            {
                this.managedCallback.SessionAbortedByPartner(
                    NativeTypes.FromBOOLEAN(isInbound),
                    svcInstance,
                    NativeTypes.FromNativeString(partitionKey),
                    closingSession);
            }
        }
Exemplo n.º 2
0
        public int AcceptInboundSession(
            NativeReliableMessaging.IFabricReliableSessionPartitionIdentity partitionId,
            NativeReliableMessaging.IFabricReliableSession session)
        {
            var offeredSession = ReliableMessagingSession.FromNative(session);

            var nativeSvcName = partitionId.getServiceName();
            var svcInstance   = NativeTypes.FromNativeUri(nativeSvcName);

            var result = false;

            var partitionKeyType = partitionId.getPartitionKeyType();
            var partitionKey     = partitionId.getPartitionKey();

            if (partitionKeyType == NativeTypes.FABRIC_PARTITION_KEY_TYPE.FABRIC_PARTITION_KEY_TYPE_NONE)
            {
                result = this.managedCallback.AcceptInboundSession(svcInstance, offeredSession);
            }
            else if (partitionKeyType == NativeTypes.FABRIC_PARTITION_KEY_TYPE.FABRIC_PARTITION_KEY_TYPE_INT64)
            {
                var int64KeyRange = IntegerPartitionKeyRangeFactory.FromNative(partitionKey);
                result = this.managedCallback.AcceptInboundSession(svcInstance, int64KeyRange, offeredSession);
            }
            else if (partitionKeyType == NativeTypes.FABRIC_PARTITION_KEY_TYPE.FABRIC_PARTITION_KEY_TYPE_STRING)
            {
                result = this.managedCallback.AcceptInboundSession(svcInstance, NativeTypes.FromNativeString(partitionKey), offeredSession);
            }

            // TODO: if the key is an unknown type should be invalif arg
            // TODO: this whole boolean return API needs update
            if (result)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }