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();
                }
            }
        }
示例#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);
        }
        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));
        }
        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));
        }
        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));
        }
示例#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);
        }
示例#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);
        }
        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);
            }
        }
示例#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);
        }
示例#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());
        }
示例#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();
                }
            }
        }