internal static Task <ServerMessage> SendConnectWebsocket(ButtplugFFIMessageSorter aSorter, ButtplugFFIClientHandle aHandle, string aAddress, bool aIgnoreCert)
        {
            var builder = new FlatBufferBuilder(1024);
            var msg     = ConnectWebsocket.CreateConnectWebsocket(builder, builder.CreateString(aAddress), aIgnoreCert);

            return(SendClientMessage(aSorter, aHandle, builder, ClientMessageType.ConnectWebsocket, msg.Value));
        }
        internal static Task <ServerMessage> SendConnectLocal(ButtplugFFIMessageSorter aSorter, ButtplugFFIClientHandle aHandle, string aServerName, uint aMaxPingTime, ushort aDeviceCommManagerTypes)
        {
            var builder = new FlatBufferBuilder(1024);
            var msg     = ConnectLocal.CreateConnectLocal(builder, builder.CreateString(aServerName), aMaxPingTime, aDeviceCommManagerTypes);

            return(SendClientMessage(aSorter, aHandle, builder, ClientMessageType.ConnectLocal, msg.Value));
        }
        internal static Task <ServerMessage> SendStopScanning(ButtplugFFIMessageSorter aSorter, ButtplugFFIClientHandle aHandle)
        {
            var builder = new FlatBufferBuilder(1024);

            StopScanning.StartStopScanning(builder);
            var msg = StopScanning.EndStopScanning(builder);

            return(SendClientMessage(aSorter, aHandle, builder, ClientMessageType.StopScanning, msg.Value));
        }
 /// <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 <MessageAttributeType, ButtplugMessageAttributes> aAllowedMessages)
 {
     Sorter          = aSorter;
     Handle          = aHandle;
     Index           = aIndex;
     Name            = aName;
     AllowedMessages = aAllowedMessages;
 }
        internal static Task <ServerMessage> SendClientMessage(ButtplugFFIMessageSorter aSorter, ButtplugFFIClientHandle aHandle, FlatBufferBuilder aBuilder, ClientMessageType aType, int aOffset)
        {
            ClientMessage.StartClientMessage(aBuilder);
            ClientMessage.AddMessageType(aBuilder, aType);
            ClientMessage.AddMessage(aBuilder, aOffset);
            var task = aSorter.PrepareClientMessage(aBuilder);
            var create_client_msg = CreateClient.EndCreateClient(aBuilder);

            aBuilder.Finish(create_client_msg.Value);
            var buf = aBuilder.SizedByteArray();

            ButtplugFFICalls.buttplug_parse_client_message(aHandle, buf, buf.Length);
            return(task);
        }
        internal static Task <ServerMessage> SendDeviceMessage(ButtplugFFIMessageSorter aSorter, ButtplugFFIDeviceHandle aHandle, uint aDeviceIndex, FlatBufferBuilder aBuilder, DeviceMessageType aType, int aOffset)
        {
            DeviceMessage.StartDeviceMessage(aBuilder);
            DeviceMessage.AddMessageType(aBuilder, aType);
            DeviceMessage.AddMessage(aBuilder, aOffset);
            DeviceMessage.AddDeviceIndex(aBuilder, aDeviceIndex);
            var task       = aSorter.PrepareClientMessage(aBuilder);
            var device_msg = DeviceMessage.EndDeviceMessage(aBuilder);

            aBuilder.Finish(device_msg.Value);
            var buf = aBuilder.SizedByteArray();

            ButtplugFFICalls.buttplug_parse_device_message(aHandle, buf, buf.Length);
            return(task);
        }
        internal static Task <ServerMessage> SendVibrateCmd(ButtplugFFIMessageSorter aSorter, ButtplugFFIDeviceHandle aHandle, uint aDeviceindex, Dictionary <uint, double> aSpeeds)
        {
            var builder      = new FlatBufferBuilder(1024);
            var command_list = new List <Offset <VibrateComponent> >();

            foreach (var pair in aSpeeds)
            {
                VibrateComponent.StartVibrateComponent(builder);
                VibrateComponent.AddIndex(builder, pair.Key);
                VibrateComponent.AddSpeed(builder, pair.Value);
                var component = VibrateComponent.EndVibrateComponent(builder);
                command_list.Add(component);
            }
            var param_array = VibrateCmd.CreateSpeedsVector(builder, command_list.ToArray());

            VibrateCmd.StartVibrateCmd(builder);
            VibrateCmd.AddSpeeds(builder, param_array);
            var cmd = VibrateCmd.EndVibrateCmd(builder);

            return(SendDeviceMessage(aSorter, aHandle, aDeviceindex, builder, DeviceMessageType.VibrateCmd, cmd.Value));
        }
 internal static Task <ServerMessage> SendRotateCmd(ButtplugFFIMessageSorter aSorter, ButtplugFFIDeviceHandle aHandle, uint aDeviceindex, Dictionary <uint, (double, bool)> aRotations)