Ejemplo n.º 1
0
        public void Send(DispatchData?content, NWEndpoint?endpoint, NWContentContext context, Action <NWError?>?handler)
        {
            unsafe {
                if (handler == null)
                {
                    nw_connection_group_send_message(GetCheckedHandle(),
                                                     content.GetHandle(),
                                                     endpoint.GetHandle(),
                                                     context.GetCheckedHandle(),
                                                     null);
                    return;
                }

                BlockLiteral block_handler = new BlockLiteral();
                block_handler.SetupBlockUnsafe(static_SendCompletion, handler);
                try {
                    nw_connection_group_send_message(GetCheckedHandle(),
                                                     content.GetHandle(),
                                                     endpoint.GetHandle(),
                                                     context.GetCheckedHandle(),
                                                     &block_handler);
                } finally {
                    block_handler.CleanupBlock();
                }
            }
        }
Ejemplo n.º 2
0
        public unsafe void SendIdempotent(DispatchData buffer, NWContentContext context, bool isComplete)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            LowLevelSend(GetCheckedHandle(), buffer, context.Handle, isComplete, (void *)NWConnectionConstants._SendIdempotentContent);
        }
Ejemplo n.º 3
0
        public NWConnection?GetConnection(NWContentContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            var ptr = nw_connection_group_extract_connection_for_message(GetCheckedHandle(), context.GetCheckedHandle());

            return(ptr == IntPtr.Zero ? null : new NWConnection(ptr, owns: true));
        }
Ejemplo n.º 4
0
        public NWEndpoint?GetRemmoteEndpoint(NWContentContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            var ptr = nw_connection_group_copy_remote_endpoint_for_message(GetCheckedHandle(), context.GetCheckedHandle());

            return(ptr == IntPtr.Zero ? null : new NWEndpoint(ptr, owns: true));
        }
Ejemplo n.º 5
0
        public NWProtocolMetadata?GetProtocolMetadata(NWContentContext context)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            var ptr = nw_connection_group_copy_protocol_metadata(GetCheckedHandle(), context.Handle);

            return(ptr == IntPtr.Zero ? null : new NWProtocolMetadata(ptr, true));
        }
Ejemplo n.º 6
0
        public void SendIdempotent(byte [] buffer, NWContentContext context, bool isComplete)
        {
            DispatchData d = null;

            if (buffer != null)
            {
                d = DispatchData.FromByteBuffer(buffer);
            }

            SendIdempotent(buffer, context, isComplete);
        }
Ejemplo n.º 7
0
        public void Send(byte [] buffer, int start, int length, NWContentContext context, bool isComplete, Action <NWError> callback)
        {
            DispatchData d = null;

            if (buffer != null)
            {
                d = DispatchData.FromByteBuffer(buffer, start, length);
            }

            Send(d, context, isComplete, callback);
        }
Ejemplo n.º 8
0
        static void TrampolineReceiveHandler(IntPtr block, IntPtr content, IntPtr context, bool isCompleted)
        {
            var del = BlockLiteral.GetTarget <NWConnectionGroupReceiveDelegate> (block);

            if (del != null)
            {
                using var nsContent = new DispatchData(content, owns: false);
                using var nsContext = new NWContentContext(context, owns: false);
                del(nsContent, nsContext, isCompleted);
            }
        }
Ejemplo n.º 9
0
        public void Send(byte [] buffer, NWContentContext context, bool isComplete, Action <NWError?> callback)
        {
            DispatchData?d = null;

            if (buffer != null)
            {
                d = DispatchData.FromByteBuffer(buffer);
            }

            Send(d, context, isComplete, callback);
        }
Ejemplo n.º 10
0
        public void Reply(NWContentContext inboundMessage, NWContentContext outboundMessage, DispatchData content)
        {
            if (inboundMessage == null)
            {
                throw new ArgumentNullException(nameof(inboundMessage));
            }
            if (outboundMessage == null)
            {
                throw new ArgumentNullException(nameof(outboundMessage));
            }

            nw_connection_group_reply(GetCheckedHandle(), inboundMessage.GetCheckedHandle(), outboundMessage.GetCheckedHandle(), content.GetHandle());
        }
Ejemplo n.º 11
0
        public void Send(DispatchData buffer, NWContentContext context, bool isComplete, Action <NWError> callback)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (callback == null)
            {
                throw new ArgumentNullException(nameof(callback));
            }

            unsafe {
                BlockLiteral  block_handler     = new BlockLiteral();
                BlockLiteral *block_ptr_handler = &block_handler;
                block_handler.SetupBlockUnsafe(static_SendCompletion, callback);

                try {
                    LowLevelSend(GetCheckedHandle(), buffer, context.Handle, isComplete, block_ptr_handler);
                } finally {
                    block_handler.CleanupBlock();
                }
            }
        }