Exemplo n.º 1
0
        internal static Task <ButtplugFFIServerMessage> SendConnectLocal(
            ButtplugFFIMessageSorter aSorter,
            ButtplugFFIClientHandle aHandle,
            string aServerName,
            uint aMaxPingTime,
            bool aAllowRawMessages,
            string aDeviceConfigJSON,
            string aUserDeviceConfigJSON,
            ushort aDeviceCommManagerTypes,
            ButtplugCallback aCallback,
            IntPtr aCallbackCtx)
        {
            var msg = new ClientMessage();

            msg.Message = new ClientMessage.Types.FFIMessage();
            msg.Message.ConnectLocal = new ClientMessage.Types.ConnectLocal
            {
                ServerName                  = aServerName,
                MaxPingTime                 = aMaxPingTime,
                AllowRawMessages            = aAllowRawMessages,
                DeviceConfigurationJson     = aDeviceConfigJSON ?? "",
                UserDeviceConfigurationJson = aUserDeviceConfigJSON ?? "",
                CommManagerTypes            = aDeviceCommManagerTypes
            };
            return(SendClientMessage(aSorter, aHandle, msg, aCallback, aCallbackCtx));
        }
Exemplo n.º 2
0
        internal static Task <ButtplugFFIServerMessage> SendVibrateCmd(ButtplugFFIMessageSorter aSorter, ButtplugFFIDeviceHandle aHandle, uint aDeviceIndex, Dictionary <uint, double> aSpeeds, ButtplugCallback aCallback, IntPtr aCallbackCtx)
        {
            var command_list = new List <DeviceMessage.Types.VibrateComponent>();

            foreach (var pair in aSpeeds)
            {
                command_list.Add(new DeviceMessage.Types.VibrateComponent
                {
                    Index = pair.Key,
                    Speed = pair.Value,
                });
            }

            var cmd = new DeviceMessage.Types.VibrateCmd();

            cmd.Speeds.Add(command_list);

            var msg = new DeviceMessage
            {
                Index   = aDeviceIndex,
                Message = new DeviceMessage.Types.FFIMessage
                {
                    VibrateCmd = cmd
                }
            };

            return(SendDeviceMessage(aSorter, aHandle, msg, aCallback, aCallbackCtx));
        }
Exemplo n.º 3
0
        internal static Task <ButtplugFFIServerMessage> SendClientMessage(ButtplugFFIMessageSorter aSorter, ButtplugFFIClientHandle aHandle, ClientMessage aMsg, ButtplugCallback aCallback, IntPtr aCallbackCtx)
        {
            var task = aSorter.PrepareClientMessage(aMsg);
            var buf  = aMsg.ToByteArray();

            ButtplugFFICalls.buttplug_client_protobuf_message(aHandle, buf, buf.Length, aCallback, aCallbackCtx);
            return(task);
        }
Exemplo n.º 4
0
        internal static Task <ButtplugFFIServerMessage> SendDisconnect(ButtplugFFIMessageSorter aSorter, ButtplugFFIClientHandle aHandle, ButtplugCallback aCallback, IntPtr aCallbackCtx)
        {
            var msg = new ClientMessage();

            msg.Message            = new ClientMessage.Types.FFIMessage();
            msg.Message.Disconnect = new ClientMessage.Types.Disconnect();
            return(SendClientMessage(aSorter, aHandle, msg, aCallback, aCallbackCtx));
        }
Exemplo n.º 5
0
        internal static Task <ButtplugFFIServerMessage> SendClientMessage(ButtplugFFIMessageSorter aSorter, ButtplugFFIClientHandle aHandle, ClientMessage aMsg)
        {
            var task = aSorter.PrepareClientMessage(aMsg);
            var buf  = aMsg.ToByteArray();

            ButtplugFFICalls.buttplug_parse_client_message(aHandle, buf, buf.Length);
            return(task);
        }
Exemplo n.º 6
0
        internal static Task <ButtplugFFIServerMessage> SendDeviceMessage(ButtplugFFIMessageSorter aSorter, ButtplugFFIDeviceHandle aHandle, DeviceMessage aMsg, ButtplugCallback aCallback, IntPtr aCallbackCtx)
        {
            var task = aSorter.PrepareDeviceMessage(aMsg);
            var buf  = aMsg.ToByteArray();

            ButtplugFFICalls.ButtplugDeviceProtobufMessage(aHandle, buf, buf.Length, aCallback, aCallbackCtx);
            return(task);
        }
Exemplo n.º 7
0
        internal static Task <ButtplugFFIServerMessage> SendStopAllDevices(ButtplugFFIMessageSorter aSorter, ButtplugFFIClientHandle aHandle, ButtplugCallback aCallback, IntPtr aCallbackCtx)
        {
            var msg = new ClientMessage();

            msg.Message = new ClientMessage.Types.FFIMessage();
            msg.Message.StopAllDevices = new ClientMessage.Types.StopAllDevices
            {
            };
            return(SendClientMessage(aSorter, aHandle, msg, aCallback, aCallbackCtx));
        }
Exemplo n.º 8
0
        internal static Task <ButtplugFFIServerMessage> SendPing(ButtplugFFIMessageSorter aSorter, ButtplugFFIClientHandle aHandle)
        {
            var msg = new ClientMessage();

            msg.Message      = new ClientMessage.Types.FFIMessage();
            msg.Message.Ping = new ClientMessage.Types.Ping
            {
            };
            return(SendClientMessage(aSorter, aHandle, msg));
        }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ButtplugClientDevice"/> class, using
 /// discrete parameters.
 /// </summary>
 /// <param name="aIndex">The device index.</param>
 /// <param name="aName">The device name.</param>
 /// <param name="aMessages">The device allowed message list, with corresponding attributes.</param>
 internal ButtplugClientDevice(ButtplugFFIMessageSorter aSorter,
                               ButtplugFFIDeviceHandle aHandle,
                               uint aIndex,
                               string aName,
                               Dictionary <ServerMessage.Types.MessageAttributeType, ButtplugMessageAttributes> aAllowedMessages)
 {
     Sorter          = aSorter;
     Handle          = aHandle;
     Index           = aIndex;
     Name            = aName;
     AllowedMessages = aAllowedMessages;
 }
Exemplo n.º 10
0
        internal static Task <ButtplugFFIServerMessage> SendConnectWebsocket(ButtplugFFIMessageSorter aSorter, ButtplugFFIClientHandle aHandle, string aAddress, bool aIgnoreCert, ButtplugCallback aCallback, IntPtr aCallbackCtx)
        {
            var msg = new ClientMessage();

            msg.Message = new ClientMessage.Types.FFIMessage();
            msg.Message.ConnectWebsocket = new ClientMessage.Types.ConnectWebsocket
            {
                Address = aAddress,
                BypassCertVerification = aIgnoreCert,
            };
            return(SendClientMessage(aSorter, aHandle, msg, aCallback, aCallbackCtx));
        }
Exemplo n.º 11
0
        internal static Task <ButtplugFFIServerMessage> SendPing(ButtplugFFIMessageSorter aSorter, ButtplugFFIClientHandle aHandle, ButtplugCallback aCallback, IntPtr aCallbackCtx)
        {
            var msg = new ClientMessage
            {
                Message = new ClientMessage.Types.FFIMessage
                {
                    Ping = new ClientMessage.Types.Ping()
                }
            };

            return(SendClientMessage(aSorter, aHandle, msg, aCallback, aCallbackCtx));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ButtplugClientDevice"/> class, using
 /// discrete parameters.
 /// </summary>
 /// <param name="aIndex">The device index.</param>
 /// <param name="aName">The device name.</param>
 /// <param name="aAllowedMessages">The device allowed message list, with corresponding attributes.</param>
 internal ButtplugClientDevice(ButtplugFFIMessageSorter aSorter,
                               ButtplugFFIDeviceHandle aHandle,
                               uint aIndex,
                               string aName,
                               Dictionary <ServerMessage.Types.MessageAttributeType, ButtplugMessageAttributes> aAllowedMessages,
                               ButtplugCallback aCallback,
                               IntPtr aCallbackCtx)
 {
     _disposeLock       = new object();
     _disposed          = false;
     _sorter            = aSorter;
     _handle            = aHandle;
     Index              = aIndex;
     Name               = aName;
     AllowedMessages    = aAllowedMessages;
     _sorterCallback    = aCallback;
     _sorterCallbackCtx = aCallbackCtx;
 }
Exemplo n.º 13
0
        protected ButtplugClient(string aClientName, ButtplugCallback aCallback)
        {
            Name = aClientName;
            _sorterCallbackDelegate = aCallback;
            _disposeLock            = new object();

            _messageSorter = new ButtplugFFIMessageSorter();
            _devices       = new Dictionary <uint, ButtplugClientDevice>();

            var context     = new WeakReference(this);
            var clientIndex = _clientCounter;

            _clientCounter += 1;

            // Since we can pass the handle, I don't *think* this needs to be pinned?
            _indexHandle = GCHandle.Alloc(clientIndex);
            _clientStorage.Add(clientIndex, context);
            _clientHandle = ButtplugFFI.SendCreateClient(aClientName, _sorterCallbackDelegate, GCHandle.ToIntPtr(_indexHandle));
        }
Exemplo n.º 14
0
        internal static Task <ButtplugFFIServerMessage> SendVibrateCmd(ButtplugFFIMessageSorter aSorter, ButtplugFFIDeviceHandle aHandle, uint aDeviceIndex, Dictionary <uint, double> aSpeeds)
        {
            var msg = new DeviceMessage();

            msg.Message = new DeviceMessage.Types.FFIMessage();
            var command_list = new List <DeviceMessage.Types.VibrateComponent>();

            foreach (var pair in aSpeeds)
            {
                command_list.Add(new DeviceMessage.Types.VibrateComponent {
                    Index = pair.Key,
                    Speed = pair.Value,
                });
            }
            msg.Index = aDeviceIndex;
            var vibrate_cmd = new DeviceMessage.Types.VibrateCmd();

            vibrate_cmd.Speeds.Add(command_list);
            msg.Message.VibrateCmd = vibrate_cmd;
            return(SendDeviceMessage(aSorter, aHandle, msg));
        }
Exemplo n.º 15
0
 internal static Task <ButtplugFFIServerMessage> SendRotateCmd(ButtplugFFIMessageSorter aSorter, ButtplugFFIDeviceHandle aHandle, uint aDeviceIndex, Dictionary <uint, (double, bool)> aRotations, ButtplugCallback aCallback, IntPtr aCallbackCtx)