Ejemplo n.º 1
0
        /// <summary>
        /// Creates an procedure called by a remote client that can be polled by the server
        /// </summary>
        /// <remarks>
        /// Note that this can only be called by a server.
        /// </remarks>
        /// <param name="name">The name for this Rpc</param>
        /// <param name="def">The definition for this Rpc</param>
        public static void CreatePolledRpc(string name, byte[] def)
        {
#if CORE
            UIntPtr nameLen;
            IntPtr  nameB = CoreMethods.CreateCachedUTF8String(name, out nameLen);
            Interop.NT_CreatePolledRpc(nameB, nameLen, def, (UIntPtr)def.Length);
#else
            Storage.Instance.CreatePolledRpc(name, def);
#endif
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Calls a procedure on a remote server
        /// </summary>
        /// <param name="name">The name of the Rpc</param>
        /// <param name="param">The data to send for the request</param>
        /// <returns>The Rpc call id</returns>
        public static long CallRpc(string name, params byte[] param)
        {
#if CORE
            UIntPtr size;
            IntPtr  nameB = CoreMethods.CreateCachedUTF8String(name, out size);
            return(Interop.NT_CallRpc(nameB, size, param, (UIntPtr)param.Length));
#else
            return(Storage.Instance.CallRpc(name, param));
#endif
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates an procedure that can be called by a remote client
        /// </summary>
        /// <remarks>
        /// Note that this can only be called by a server.
        /// </remarks>
        /// <param name="name">The name for this Rpc</param>
        /// <param name="def">The definition for this Rpc</param>
        /// <param name="callback">The callback to use the the procedure is called from a remote</param>
        public static void CreateRpc(string name, byte[] def, RpcCallback callback)
        {
#if CORE
            Interop.NT_RPCCallback modCallback =
                (IntPtr data, IntPtr ptr, UIntPtr len, IntPtr intPtr, UIntPtr paramsLen, out UIntPtr resultsLen) =>
            {
                string retName = CoreMethods.ReadUTF8String(ptr, len);
                byte[] param   = CoreMethods.GetRawDataFromPtr(intPtr, paramsLen);
                byte[] cb      = callback(retName, param);
                resultsLen = (UIntPtr)cb.Length;
                IntPtr retPtr = Interop.NT_AllocateCharArray(resultsLen);
                Marshal.Copy(cb, 0, retPtr, cb.Length);
                return(retPtr);
            };
            UIntPtr nameLen;
            IntPtr  nameB = CoreMethods.CreateCachedUTF8String(name, out nameLen);
            Interop.NT_CreateRpc(nameB, nameLen, def, (UIntPtr)def.Length, IntPtr.Zero, modCallback);
            s_rpcCallbacks.Add(modCallback);
#else
            Storage.Instance.CreateRpc(name, def, callback);
#endif
        }