Lovense Integration
|
Abstract base class for Lovense adapters.
These adapters handle the communication with the Lovense API's and hold the toy objects for the toys which are connected to the respective Lovense App.
Each Lovense API+Platform combination has different requirements, so they get their own adapter implementation.
Multiple adapters can be active at the same time, one for each Lovense App instance found in the local network.
More...
#include <LovenseIntegration/Source/LovenseIntegration/Classes/Adapters/ILovenseAdapter.h>
Public Member Functions | |
const FORCEINLINE FLovenseAdapterDescription & | GetAdapterDescription () |
The adapter description that was used to initialize this adapter. Holds (mostly) raw TryGetAdapterData() HTTP request json data for this adapter. | |
const TArray< TPair< FString, FTimerHandle > > | GetToyTestTimerHandles () |
Array of toy deviceId string and test timer handle. This holds the toy deviceId so we can check if a toy is running a test command and to send a command to that toy to stop vibrating when the timer finishes. | |
virtual bool | Initialize (FLovenseAdapterDescription &description) |
Initializes the adapter with the passed in adapter description. More... | |
virtual void | Shutdown () |
Deinitialize the adapter. This will stop any running test timers and clear toy objects. | |
virtual bool | GetToys (FOnLovenseGetToysResponse callback) |
Polls the Lovense App for toys and creates toy objects for all received toys. We always directly poll the respective Lovense Apps to get our toy info so we don't put unnecessary load on the Lovense servers. More... | |
virtual bool | SendCommand_Test (const FString &toyId) |
See FLovenseManager::SendCommand_Test() for information on this command. More... | |
virtual bool | SendCommand_Stop (const FString ¶meters, const FString &toyId) |
See FLovenseManager::SendCommand_Stop() for information on this command. More... | |
virtual bool | SendCommand_Vibrate (const FString ¶meters, const FString &toyId, uint8 vibrationSpeed) |
See FLovenseManager::SendCommand_Vibrate() for information on this command. More... | |
virtual bool | SendCommand_Vibrate1 (const FString ¶meters, const FString &toyId, uint8 vibrationSpeed) |
See FLovenseManager::SendCommand_Vibrate1() for information on this command. More... | |
virtual bool | SendCommand_Vibrate2 (const FString ¶meters, const FString &toyId, uint8 vibrationSpeed) |
See FLovenseManager::SendCommand_Vibrate2() for information on this command. More... | |
virtual bool | SendCommand_Rotate (const FString ¶meters, const FString &toyId, uint8 rotationSpeed) |
See FLovenseManager::SendCommand_Rotate() for information on this command. More... | |
virtual bool | SendCommand_RotateAntiClockwise (const FString ¶meters, const FString &toyId, uint8 rotationSpeed) |
See FLovenseManager::SendCommand_RotateAntiClockwise() for information on this command. More... | |
virtual bool | SendCommand_RotateClockwise (const FString ¶meters, const FString &toyId, uint8 rotationSpeed) |
See FLovenseManager::SendCommand_RotateClockwise() for information on this command. More... | |
virtual bool | SendCommand_RotateChange (const FString ¶meters, const FString &toyId) |
See FLovenseManager::SendCommand_RotateChange() for information on this command. More... | |
virtual bool | SendCommand_AirAuto (const FString ¶meters, const FString &toyId, uint8 pulseSpeed) |
See FLovenseManager::SendCommand_AirAuto() for information on this command. More... | |
virtual bool | SendCommand_AirIn (const FString ¶meters, const FString &toyId) |
See FLovenseManager::SendCommand_AirIn() for information on this command. More... | |
virtual bool | SendCommand_AirOut (const FString ¶meters, const FString &toyId) |
See FLovenseManager::SendCommand_AirOut() for information on this command. More... | |
virtual bool | SendCommand_Thrust (const FString ¶meters, const FString &toyId, uint8 thrustingSpeed) |
See FLovenseManager::SendCommand_Vibrate() for information on this command. More... | |
virtual bool | SendCommand_Suck (const FString ¶meters, const FString &toyId, uint8 suctionSpeed) |
See FLovenseManager::SendCommand_Vibrate() for information on this command. More... | |
virtual bool | SendCommand_Finger (const FString ¶meters, const FString &toyId, uint8 fingeringSpeed) |
See FLovenseManager::SendCommand_Vibrate() for information on this command. More... | |
virtual bool | SendCommand_Preset (const FString ¶meters, const FString &toyId, uint8 pattern) |
See FLovenseManager::SendCommand_Preset() for information on this command. More... | |
virtual bool | SendCommand_Battery (const FString ¶meters, const FString &toyId, FOnLovenseResponse callback) |
See FLovenseManager::SendCommand_Battery() for information on this command. More... | |
virtual bool | SendCommand_AVibrate (const FString ¶meters, const FString &toyId, uint8 vibrationSpeed, int32 time) |
See FLovenseManager::SendCommand_AVibrate() for information on this command. More... | |
virtual bool | SendCommand_AVibrate1 (const FString ¶meters, const FString &toyId, uint8 vibrationSpeed, int32 time) |
See FLovenseManager::SendCommand_AVibrate1() for information on this command. More... | |
virtual bool | SendCommand_AVibrate2 (const FString ¶meters, const FString &toyId, uint8 vibrationSpeed, int32 time) |
See FLovenseManager::SendCommand_AVibrate2() for information on this command. More... | |
virtual bool | SendCommand_ARotate (const FString ¶meters, const FString &toyId, uint8 rotationSpeed, int32 time) |
See FLovenseManager::SendCommand_ARotate() for information on this command. More... | |
virtual bool | SendCommand_AAirLevel (const FString ¶meters, const FString &toyId, uint8 pulseSpeed, int32 time) |
See FLovenseManager::SendCommand_AAirLevel() for information on this command. More... | |
virtual bool | SendCommand_AThrust (const FString ¶meters, const FString &toyId, uint8 thrustingSpeed, int32 time) |
See FLovenseManager::SendCommand_AThrust() for information on this command. More... | |
virtual bool | SendCommand_ASuck (const FString ¶meters, const FString &toyId, uint8 suctionSpeed, int32 time) |
See FLovenseManager::SendCommand_ASuck() for information on this command. More... | |
virtual bool | SendCommand_AFinger (const FString ¶meters, const FString &toyId, uint8 fingeringSpeed, int32 time) |
See FLovenseManager::SendCommand_AFinger() for information on this command. More... | |
virtual bool | SendCommand_APreset (const FString ¶meters, const FString &toyId, const FString &patternName, int32 time) |
See FLovenseManager::SendCommand_APreset() for information on this command. More... | |
virtual bool | SendCommand_AVibRotate (const FString ¶meters, const FString &toyId, uint8 vibrationSpeed, uint8 rotationSpeed, int32 time) |
See FLovenseManager::SendCommand_AVibRotate() for information on this command. More... | |
virtual bool | SendCommand_AVibAir (const FString ¶meters, const FString &toyId, uint8 vibrationSpeed, uint8 pulseSpeed, int32 time) |
See FLovenseManager::SendCommand_AVibAir() for information on this command. More... | |
virtual bool | SendCommand_AVibRotateAir (const FString ¶meters, const FString &toyId, uint8 vibrationSpeed, uint8 rotationSpeed, uint8 pulseSpeed, int32 time) |
See FLovenseManager::SendCommand_AVibRotateAir() for information on this command. More... | |
virtual bool | SendCommand_AAll (const FString ¶meters, const FString &toyId, uint8 vibrationSpeed, uint8 rotationSpeed, uint8 pulseSpeed, uint8 thrustingSpeed, uint8 fingeringSpeed, uint8 suctionSpeed, int32 time) |
See FLovenseManager::SendCommand_AAll() for information on this command. More... | |
virtual bool | SendCommand_Pattern (const FString ¶meters, const FString &toyId, FLovensePattern &pattern) |
See FLovenseManager::SendCommand_Pattern() for information on this command. More... | |
Static Public Member Functions | |
static bool | TryGetAdapterData (FOnLovenseGetAdaptersResponse callback) |
Polls "https://api.lovense-api.com/api/lan/v2/app" for toys in the local network. This is the same for all API+Platform combinations, so we can make it static. More... | |
Protected Member Functions | |
ILovenseAdapter (const ILovenseAdapter &) | |
virtual FHttpRequestPtr | CreateHTTPRequest_GetToys ()=0 |
Create HTTP request to poll for toy info. Each API+Platform combination requires different HTTP request settings, so allow child classes to create the HTTP request with the correct settings. | |
virtual FHttpRequestPtr | CreateHTTPRequest_SendCommand (const FString ¶meters)=0 |
Create HTTP request to send a command. Each API+Platform combination requires different HTTP request settings, so allow child classes to create the HTTP request with the correct settings. More... | |
void | CreateLovenseToy (FLovenseToyDescription &toyDescription) |
Creates a toy object and adds it to the toyStrongPointers array. Also adds the toyDescription to the responseData.toys array. | |
virtual void | GetToysDataJsonObject (TSharedPtr< class FJsonObject > jsonObject, TSharedPtr< class FJsonObject > &outToysJsonObject) |
Retrieve a json object holding an array of toys. The json structure is different between the API's, so allow child classes to override this. More... | |
virtual void | ParseToyDescription (FLovenseToyDescription &outToyDescription, TSharedPtr< class FJsonObject > toyObject)=0 |
Parses a json object holding toy data and fills a toy description. The json structure is different between the API's, so allow child classes to override this. More... | |
virtual bool | SendCommand (const FString ¶meters, FOnLovenseResponse callback=FOnLovenseResponse()) |
Send a HTTP request to the respective Lovense App. More... | |
virtual void | OnToyTestTimerFinished () |
Test timer finished event. Will set vibration speed of the relevant toy to 0 and remove the relevant timer handle from the toyTestTimerHandles array. | |
Static Protected Member Functions | |
static TSharedPtr< class ILovenseAdapter > | CreateLovenseAdapter (const FLovenseAdapterDescription &adapterDescription) |
Factory function for lovense adapters. Checks the adapterDescription.platform and adapterDescription.appType strings to determine which adapter should be created. | |
Protected Attributes | |
TSharedPtr< class LovenseToyEventsWebSocketHandler > | lovenseToyEventsWebSocketHandler |
FLovenseAdapterDescription | adapterDescription |
The adapter description that was used to initialize this adapter. Holds (mostly) raw TryGetAdapterData() HTTP request json data for this adapter. | |
FString | deviceIp |
Device IP string (excluding port) the Lovense App instance is running on. Parsed in Initialize(). | |
FString | webProtocol |
The web protocol to use. Default is HTTPS, but will be set to HTTP if li.Request.UseDirectIP is true as the SSL certificate does not work with direct IPs and we can't ignore SSL host verification without modifying the engine. | |
FLovenseGetToysResponseData | responseData |
Holds (mostly) raw GetToys() HTTP request json data. | |
TArray< TStrongObjectPtr< class ULovenseToy > > | toyStrongPointers |
Array of the Lovense toy object instances. Is strong object pointer so these UObjects aren't gc'd. | |
TArray< TPair< FString, FTimerHandle > > | toyTestTimerHandles |
Array of toy deviceId string and test timer handle. This holds the toy deviceId so we can check if a toy is running a test command and to send a command to that toy to stop vibrating when the timer finishes. | |
Friends | |
class | FLovenseManager |
Abstract base class for Lovense adapters.
These adapters handle the communication with the Lovense API's and hold the toy objects for the toys which are connected to the respective Lovense App.
Each Lovense API+Platform combination has different requirements, so they get their own adapter implementation.
Multiple adapters can be active at the same time, one for each Lovense App instance found in the local network.
|
protectedpure virtual |
Create HTTP request to send a command.
Each API+Platform combination requires different HTTP request settings, so allow child classes to create the HTTP request with the correct settings.
parameters | String defining the URI path and query (including '?') for the request. |
Implemented in LovenseTestAdapter, LovenseRemoteAdapterBase, LovenseConnectDesktopAdapter, and LovenseConnectMobileAdapter.
|
virtual |
Polls the Lovense App for toys and creates toy objects for all received toys.
We always directly poll the respective Lovense Apps to get our toy info so we don't put unnecessary load on the Lovense servers.
callback | Called when HTTP request has been completed. If request was unsuccessful, will pass an empty toy object array. FLovenseGetToysResponseData might be partially filled in. This will not be called if the integration is not running. |
|
protectedvirtual |
Retrieve a json object holding an array of toys. The json structure is different between the API's, so allow child classes to override this.
jsonObject | Json object holding the GetToys request response data. |
outToysJsonObject | Result json object holding the array of toys. |
Reimplemented in LovenseRemoteAdapterBase.
|
virtual |
Initializes the adapter with the passed in adapter description.
|
protectedpure virtual |
Parses a json object holding toy data and fills a toy description. The json structure is different between the API's, so allow child classes to override this.
outToyDescription | Result toy description data. Will not be default initialized. |
toyObject | Json object holding data for a single toy. |
Implemented in LovenseRemoteAdapterBase, and LovenseConnectAdapterBase.
|
protectedvirtual |
Send a HTTP request to the respective Lovense App.
parameters | String defining the URI path and query for the request. |
callback | Called when HTTP request has been completed. If request was unsuccessful, will pass -1, otherwise will pass value of "data" json field. This is used to poll battery status. This will not be called if the integration was stopped while the HTTP request was being processed. |
|
inlinevirtual |
See FLovenseManager::SendCommand_AAirLevel() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified, pulseSpeed and time. |
toyId | Used by Lovense Remote implementations. |
pulseSpeed | Used by Lovense Remote implementations. |
time | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_AAll() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified, speed and time. |
toyId | Used by Lovense Remote implementations. |
vibrationSpeed | Used by Lovense Remote implementations. |
rotationSpeed | Used by Lovense Remote implementations. |
pulseSpeed | Used by Lovense Remote implementations. |
thrustingSpeed | Used by Lovense Remote implementations. |
fingeringSpeed | Used by Lovense Remote implementations. |
suctionSpeed | Used by Lovense Remote implementations. |
time | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_AFinger() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified, fingeringSpeed and time. |
toyId | Used by Lovense Remote implementations. |
fingeringSpeed | Used by Lovense Remote implementations. |
time | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_AirAuto() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified and pulseSpeed. |
toyId | Used by Lovense Remote implementations. |
pulseSpeed | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_AirIn() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified. |
toyId | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_AirOut() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified. |
toyId | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_APreset() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified and pattern. |
toyId | Used by Lovense Remote implementations. |
patternName | Used by Lovense Remote implementations. |
time | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_ARotate() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified, rotationSpeed and time. |
toyId | Used by Lovense Remote implementations. |
rotationSpeed | Used by Lovense Remote implementations. |
time | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_ASuck() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified, suctionSpeed and time. |
toyId | Used by Lovense Remote implementations. |
suctionSpeed | Used by Lovense Remote implementations. |
time | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_AThrust() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified, thrustingSpeed and time. |
toyId | Used by Lovense Remote implementations. |
thrustingSpeed | Used by Lovense Remote implementations. |
time | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_AVibAir() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified, vibrationSpeed, pulseSpeed and time. |
toyId | Used by Lovense Remote implementations. |
vibrationSpeed | Used by Lovense Remote implementations. |
pulseSpeed | Used by Lovense Remote implementations. |
time | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_AVibrate() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified, vibrationSpeed and time. |
toyId | Used by Lovense Remote implementations. |
vibrationSpeed | Used by Lovense Remote implementations. |
time | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_AVibrate1() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified, vibrationSpeed and time. |
toyId | Used by Lovense Remote implementations. |
vibrationSpeed | Used by Lovense Remote implementations. |
time | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_AVibrate2() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified, vibrationSpeed and time. |
toyId | Used by Lovense Remote implementations. |
vibrationSpeed | Used by Lovense Remote implementations. |
time | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_AVibRotate() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified, vibrationSpeed, rotationSpeed and time. |
toyId | Used by Lovense Remote implementations. |
vibrationSpeed | Used by Lovense Remote implementations. |
rotationSpeed | Used by Lovense Remote implementations. |
time | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_AVibRotateAir() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified, vibrationSpeed, rotationSpeed, pulseSpeed and time. |
toyId | Used by Lovense Remote implementations. |
vibrationSpeed | Used by Lovense Remote implementations. |
rotationSpeed | Used by Lovense Remote implementations. |
pulseSpeed | Used by Lovense Remote implementations. |
time | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_Battery() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified. |
toyId | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_Vibrate() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified and fingeringSpeed. |
toyId | Used by Lovense Remote implementations. |
fingeringSpeed | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_Pattern() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified and pattern. |
toyId | Used by Lovense Remote implementations. |
pattern | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_Preset() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified and pattern. |
toyId | Used by Lovense Remote implementations. |
pattern | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_Rotate() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified and rotationSpeed. |
toyId | Used by Lovense Remote implementations. |
rotationSpeed | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_RotateAntiClockwise() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified and rotationSpeed. |
toyId | Used by Lovense Remote implementations. |
rotationSpeed | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_RotateChange() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified. |
toyId | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_RotateClockwise() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified and rotationSpeed. |
toyId | Used by Lovense Remote implementations. |
rotationSpeed | Used by Lovense Remote implementations. |
|
virtual |
See FLovenseManager::SendCommand_Stop() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified. |
toyId | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_Vibrate() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified and suctionSpeed. |
toyId | Used by Lovense Remote implementations. |
suctionSpeed | Used by Lovense Remote implementations. |
|
virtual |
See FLovenseManager::SendCommand_Test() for information on this command.
toyId | Must have a valid id, or command will fail. |
|
inlinevirtual |
See FLovenseManager::SendCommand_Vibrate() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified and thrustingSpeed. |
toyId | Used by Lovense Remote implementations. |
thrustingSpeed | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_Vibrate() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified and vibrationSpeed. |
toyId | Used by Lovense Remote implementations. |
vibrationSpeed | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_Vibrate1() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified and vibrationSpeed. |
toyId | Used by Lovense Remote implementations. |
vibrationSpeed | Used by Lovense Remote implementations. |
|
inlinevirtual |
See FLovenseManager::SendCommand_Vibrate2() for information on this command.
parameters | URI query string (including '?') used by Lovense Connect implementations. Contains toyId parameter if specified and vibrationSpeed. |
toyId | Used by Lovense Remote implementations. |
vibrationSpeed | Used by Lovense Remote implementations. |
|
static |
Polls "https://api.lovense-api.com/api/lan/v2/app" for toys in the local network.
This is the same for all API+Platform combinations, so we can make it static.
callback | Called when HTTP request has been completed. If request was unsuccessful, will pass a default initialized FLovenseGetAdaptersResponseData. This will not be called if the integration is not running. |