Exemplo n.º 1
0
 public void Start(MothraSettings settings)
 {
     MothraInterop.RegisterHandlers(_discoveredPeer, _receiveGossip, _receiveRpc);
     string[] args = BuildArgs(settings);
     MothraInterop.Start(args, args.Length);
     IsStarted = true;
 }
Exemplo n.º 2
0
        public bool SendGossip(ReadOnlySpan <byte> topicUtf8, ReadOnlySpan <byte> data)
        {
            if (!IsStarted)
            {
                return(false);
            }

            unsafe
            {
                fixed(byte *topicUtf8Ptr = topicUtf8)
                fixed(byte *dataPtr = data)
                {
                    MothraInterop.SendGossip(topicUtf8Ptr, topicUtf8.Length, dataPtr, data.Length);
                }
            }

            return(true);
        }
Exemplo n.º 3
0
        public bool SendRpcRequest(ReadOnlySpan <byte> methodUtf8, ReadOnlySpan <byte> peerUtf8, ReadOnlySpan <byte> data)
        {
            if (!IsStarted)
            {
                return(false);
            }

            unsafe
            {
                fixed(byte *methodUtf8Ptr = methodUtf8)
                fixed(byte *peerUtf8Ptr = peerUtf8)
                fixed(byte *dataPtr     = data)
                {
                    MothraInterop.SendRequest(methodUtf8Ptr, methodUtf8.Length, peerUtf8Ptr, peerUtf8.Length,
                                              dataPtr,
                                              data.Length);
                }
            }

            return(true);
        }