public void ApplySetting([In] ref TRANSPORT_SETTING_ID settingId, [In] int lengthIn, [In] IntPtr valueIn,
                                 out int lengthOut, out IntPtr valueOut)
        {
            if (!TransportSettingsId.Equals(settingId.Guid))
            {
                // This method is called from WinRT. The CLR will map the exception type to an HResult
                // and discard any error message.
                throw new NotSupportedException();
            }
            if (valueIn == IntPtr.Zero)
            {
                throw new ArgumentNullException("valueIn");
            }

            // SettingId GUID + valueIn (also a GUID)
            byte[] settingsGuid = settingId.Guid.ToByteArray();
            byte[] buffer       = new byte[settingsGuid.Length + lengthIn];
            settingsGuid.CopyTo(buffer, 0);
            if (lengthIn > 0)
            {
                // Store it for use later during the request
                Marshal.Copy(valueIn, buffer, settingsGuid.Length, lengthIn);
            }
            state.inputData = buffer;

            lengthOut = 0;
            valueOut  = IntPtr.Zero;
        }
        public void QuerySetting([In] ref TRANSPORT_SETTING_ID settingId, [In] int lengthIn, [In] IntPtr valueIn,
                                 out int lengthOut, out IntPtr valueOut)
        {
            if (!TransportSettingsId.Equals(settingId.Guid))
            {
                // This method is called from WinRT. The CLR will map the exception type to an HResult
                // and discard any error message.
                throw new NotSupportedException();
            }
            // Note that we ignore lengthIn and valueIn for this operation.
            // It should be the same as that from ApplySetting so we'll just re-use those values.

            // Wait until we've connected and set the socket option.  If it fails then the request will be aborted.
            // If it suceeds then we can assume that the socket is now push-enabled.
            state.connectComplete.WaitOne();

            byte[] result;
            if (state.result != 0)
            {
                // This is how we report errors to NotificationChannel.WaitForPushEnabled().
                // The CLR will unwrap the exception and return the error code.
                throw new Win32Exception(state.result);
            }
            else if (state.outputData != null)
            {
                result = state.outputData;
            }
            else
            {
                result = BitConverter.GetBytes((int)RtcState.ControlChannelTriggerStatus.TransportDisconnected);
            }

            lengthOut = result.Length;
            // COM memory marshal. It's the caller's responsibility to free the memory.
            valueOut = Marshal.AllocCoTaskMem(lengthOut);
            Marshal.Copy(result, 0, valueOut, lengthOut);
        }
Ejemplo n.º 3
0
 public void QuerySetting([In] ref TRANSPORT_SETTING_ID settingId, [In] int lengthIn, [In] IntPtr valueIn, out int lengthOut, out IntPtr valueOut)
 {
 }