コード例 #1
0
 public int nabtoStreamWrite(IntPtr stream, byte[] buffer, int offset, int length)
 {
     if (offset != 0)
     {
         var copyBuffer = new byte[length];
         Array.Copy(buffer, offset, copyBuffer, 0, length);
         return(Win32NativeMethods.nabtoStreamWrite(stream, copyBuffer, (IntPtr)length));
     }
     else
     {
         return(Win32NativeMethods.nabtoStreamWrite(stream, buffer, (IntPtr)length));
     }
 }
コード例 #2
0
        public int nabtoRpcSetDefaultInterface(IntPtr session, string interfaceDefinition, out string errorMessage)
        {
            IntPtr nativeResult;
            var    status = Win32NativeMethods.nabtoRpcSetDefaultInterface(session, interfaceDefinition, out nativeResult);

            if (status == NABTO_FAILED_WITH_JSON_MESSAGE)
            {
                errorMessage = MoveString(nativeResult);
            }
            else
            {
                errorMessage = null;
            }
            return(status);
        }
コード例 #3
0
        public int nabtoRpcInvoke(IntPtr session, string nabtoUrl, out string resultJson)
        {
            IntPtr nativeResult;

            var status = Win32NativeMethods.nabtoRpcInvoke(session, nabtoUrl, out nativeResult);

            if (status == NABTO_OK || status == NABTO_FAILED_WITH_JSON_MESSAGE)
            {
                resultJson = MoveString(nativeResult);
            }
            else
            {
                resultJson = null;
            }

            return(status);
        }
コード例 #4
0
        public int nabtoGetLocalDevices(out string[] devices)
        {
            IntPtr arrayBase;
            int    arrayLength;

            var status = Win32NativeMethods.nabtoGetLocalDevices(out arrayBase, out arrayLength);

            if (status == NABTO_OK)
            {
                devices = MoveStringArray(arrayBase, arrayLength);
            }
            else
            {
                devices = null;
            }

            return(status);
        }
コード例 #5
0
        // TODO Add support for the logging API.

        //public int nabtoRegisterLogCallback(NabtoLogCallbackFunc callback)
        //{
        //    return Win32NativeMethods.nabtoRegisterLogCallback(callback);
        //}

        //public int nabtoRegisterLogCallback(IntPtr callback)
        //{
        //    return Win32NativeMethods.nabtoRegisterLogCallback(callback);
        //}

        #endregion

        #region Query

        public int nabtoGetProtocolPrefixes(out string[] prefixes)
        {
            IntPtr arrayBase;
            int    arrayLength;

            var status = Win32NativeMethods.nabtoGetProtocolPrefixes(out arrayBase, out arrayLength);

            if (status == NABTO_OK)
            {
                prefixes = MoveStringArray(arrayBase, arrayLength);
            }
            else
            {
                prefixes = null;
            }

            return(status);
        }
コード例 #6
0
        public int nabtoStreamRead(IntPtr stream, out byte[] resultBuffer)
        {
            IntPtr nativeResultBuffer;
            IntPtr resultLength;

            var status = Win32NativeMethods.nabtoStreamRead(stream, out nativeResultBuffer, out resultLength);

            if (status == NABTO_OK)
            {
                if (IntPtr.Zero != resultLength)
                {
                    resultBuffer = MoveBuffer(nativeResultBuffer, resultLength);
                }
                else
                {
                    // Zero-length buffers are returned as null to avoid allocation, copying and garbage collection (especially costly when performing non-blocking polling for data)
                    Free(nativeResultBuffer);
                    resultBuffer = null;
                }
            }
            //else if (status == NABTO_FAILED) // workaround for NABTO_FAILED when a blocking nabtoStreamRead is aborted by calling nabtoShutdown.
            //{
            //    status = NABTO_OK;
            //    resultBuffer = null;
            //}
            //    // Todo
            //else if (status == NABTO_ABORTED) // workaround for NABTO_FAILED when a blocking nabtoStreamRead is aborted by calling nabtoShutdown.
            //{
            //    status = NABTO_OK;
            //    resultBuffer = null;
            //}
            //else if (status == NABTO_STREAM_CLOSED) // workaround for NABTO_FAILED when a blocking nabtoStreamRead is aborted by calling nabtoShutdown.
            //{
            //    status = NABTO_OK;
            //    resultBuffer = null;
            //}
            else
            {
                resultBuffer = null;
            }

            return(status);
        }
コード例 #7
0
        public int nabtoSubmitPostData(IntPtr session, string nabtoUrl, byte[] postBuffer, string postMimeType, out byte[] resultBuffer, out string resultMimeTypeBuffer)
        {
            IntPtr nativeResultBuffer;
            IntPtr resultLength;
            IntPtr nativeResultMimeTypeBuffer;

            var status = Win32NativeMethods.nabtoSubmitPostData(session, nabtoUrl, postBuffer, (IntPtr)postBuffer.Length, postMimeType, out nativeResultBuffer, out resultLength, out nativeResultMimeTypeBuffer);

            if (status == NABTO_OK)
            {
                resultBuffer         = MoveBuffer(nativeResultBuffer, resultLength);
                resultMimeTypeBuffer = MoveString(nativeResultMimeTypeBuffer);
            }
            else
            {
                resultBuffer         = null;
                resultMimeTypeBuffer = null;
            }

            return(status);
        }
コード例 #8
0
        public int nabtoFetchUrl(IntPtr session, string nabtoUrl, out byte[] resultBuffer, out string mimeTypeBuffer)
        {
            IntPtr nativeResultBuffer;
            IntPtr resultLength;
            IntPtr nativeMimeTypeBuffer;

            var status = Win32NativeMethods.nabtoFetchUrl(session, nabtoUrl, out nativeResultBuffer, out resultLength, out nativeMimeTypeBuffer);

            if (status == NABTO_OK)
            {
                resultBuffer   = MoveBuffer(nativeResultBuffer, resultLength);
                mimeTypeBuffer = MoveString(nativeMimeTypeBuffer);
            }
            else
            {
                resultBuffer   = null;
                mimeTypeBuffer = null;
            }

            return(status);
        }
コード例 #9
0
 public int nabtoCreateProfile(string email, string password)
 {
     return(Win32NativeMethods.nabtoCreateProfile(email, password));
 }
コード例 #10
0
 public int nabtoSignup(string email, string password)
 {
     return(Win32NativeMethods.nabtoSignup(email, password));
 }
コード例 #11
0
 public int nabtoTunnelOpenTcp(out IntPtr tunnel, IntPtr session, int localPort, string nabtoHost, string remoteHost, int remotePort)
 {
     return(Win32NativeMethods.nabtoTunnelOpenTcp(out tunnel, session, localPort, nabtoHost, remoteHost, remotePort));
 }
コード例 #12
0
 public int nabtoSetOption(string name, string value)
 {
     return(Win32NativeMethods.nabtoSetOption(name, value));
 }
コード例 #13
0
 public int nabtoStreamConnectionType(IntPtr stream, out ConnectionType type)
 {
     return(Win32NativeMethods.nabtoStreamConnectionType(stream, out type));
 }
コード例 #14
0
 public int nabtoStreamClose(IntPtr stream)
 {
     return(Win32NativeMethods.nabtoStreamClose(stream));
 }
コード例 #15
0
 public int nabtoStreamOpen(out IntPtr stream, IntPtr session, string deviceId)
 {
     return(Win32NativeMethods.nabtoStreamOpen(out stream, session, deviceId));
 }
コード例 #16
0
 public int nabtoSetApplicationName(string applicationName)
 {
     return(Win32NativeMethods.nabtoSetApplicationName(applicationName));
 }
コード例 #17
0
        // TODO Add support for the async API.

        //public int nabtoAsyncInit(IntPtr session, out IntPtr resource, string url)
        //{
        //    return Win32NativeMethods.nabtoAsyncInit(session, out resource, url);
        //}

        //public int nabtoAsyncClose(IntPtr resource)
        //{
        //    return Win32NativeMethods.nabtoAsyncClose(resource);
        //}

        //public int nabtoAsyncSetPostData(IntPtr resource, string mimeType, NabtoAsyncPostDataCallbackFunc callback, IntPtr userData)
        //{
        //    return Win32NativeMethods.nabtoAsyncSetPostData(resource, mimeType, callback, userData);
        //}

        //public int nabtoAsyncPostData(IntPtr resource, byte[] data, int dataLength)
        //{
        //    return Win32NativeMethods.nabtoAsyncPostData(resource, data, dataLength);
        //}

        //public int nabtoAsyncPostClose(IntPtr resource)
        //{
        //    return Win32NativeMethods.nabtoAsyncPostClose(resource);
        //}

        //public int nabtoAsyncFetch(IntPtr resource, NabtoAsyncStatusCallbackFunc callback, IntPtr userData)
        //{
        //    return Win32NativeMethods.nabtoAsyncFetch(resource, callback, userData);
        //}

        //public int nabtoGetAsyncData(IntPtr resource, byte[] buffer, int bufferSize, out int actualSize)
        //{
        //    return Win32NativeMethods.nabtoGetAsyncData(resource, buffer, bufferSize, out actualSize);
        //}

        //public int nabtoAbortAsync(IntPtr resource)
        //{
        //    return Win32NativeMethods.nabtoAbortAsync(resource);
        //}

        #endregion

        #region Configuration and initialization API.

        public int nabtoVersion(out int major, out int minor)
        {
            return(Win32NativeMethods.nabtoVersion(out major, out minor));
        }
コード例 #18
0
 public int nabtoStartup(string nabtoHomeDirectory)
 {
     return(Win32NativeMethods.nabtoStartup(nabtoHomeDirectory));
 }
コード例 #19
0
 public int nabtoOpenSessionBare(out IntPtr session)
 {
     return(Win32NativeMethods.nabtoOpenSessionBare(out session));
 }
コード例 #20
0
 public int nabtoTunnelInfo(IntPtr tunnel, TunnelInfoSelector index, int infoSize, out int info)
 {
     return(Win32NativeMethods.nabtoTunnelInfo(tunnel, index, infoSize, out info));
 }
コード例 #21
0
 public int nabtoTunnelClose(IntPtr tunnel)
 {
     return(Win32NativeMethods.nabtoTunnelClose(tunnel));
 }
コード例 #22
0
 public int nabtoResetAccountPassword(string email)
 {
     return(Win32NativeMethods.nabtoResetAccountPassword(email));
 }
コード例 #23
0
 public int nabtoSetStaticResourceDir(string resourceDirectory)
 {
     return(Win32NativeMethods.nabtoSetStaticResourceDir(resourceDirectory));
 }
コード例 #24
0
 public int nabtoStreamSetOption(IntPtr stream, StreamOption optionName, int optionValue, int optionLength)
 {
     return(Win32NativeMethods.nabtoStreamSetOption(stream, optionName, ref optionValue, (IntPtr)optionLength));
 }
コード例 #25
0
 public int nabtoInstallDefaultStaticResources(string resourceDirectory)
 {
     return(Win32NativeMethods.nabtoInstallDefaultStaticResources(resourceDirectory));
 }
コード例 #26
0
 public int nabtoProbeNetwork(int timeoutMilliseconds, string host)
 {
     return(Win32NativeMethods.nabtoProbeNetwork((IntPtr)timeoutMilliseconds, host));
 }
コード例 #27
0
 public int nabtoCloseSession(IntPtr session)
 {
     return(Win32NativeMethods.nabtoCloseSession(session));
 }
コード例 #28
0
 public int nabtoShutdown()
 {
     return(Win32NativeMethods.nabtoShutdown());
 }
コード例 #29
0
 public int nabtoOpenSession(out IntPtr session, string email, string password)
 {
     return(Win32NativeMethods.nabtoOpenSession(out session, email, password));
 }