• Hi Guest!

    Please be aware that we have released another critical security patch for VaM. We strongly recommend updating to version 1.22.0.12 using the VaM_Updater found in your installation folder.

    Details about the security patch can be found here.

Question Using System.Net.Http to communicate with Rest-Service?

opium1981

New member
Messages
7
Reactions
2
Points
3
Hey all!

I am fiddling around with Plugins and to access a device, I need to communicate with it using REST. For that I am trying to use an HttpClient which comes with System.Net.Http. However, even though it is supposed to be part of .NET 4.6.1, VaM simply tells me that it can't find the referenced DLL.

Is this a security measure? Does anybody know how I would go about something like this?
 
You will not be able to use a different versions of what is included in the build OR anything "forbidden" by the c# compiler (for instance reflections).

That's somewhat similar as any game with a "built in" engine/compiler. You cannot include/reference random libraries at will : )
 
Upvote 0
Well yeah, I do understand that. But according to Microsoft, the System.Net.Http library is included since .Net 4.6.1, which is the version VaM uses. And Visual Studio is not showing any errors like it would if the library wasn't included. So it's not any random library, it's supposed to be part of the .Net Framework runtime.
 
Upvote 0
No it is not : D
It probably is for .Net, but not for Unity.

When building the game you add the requirements/includes you need. In this case, it means VAM hasn't been built with that lib referenced for the final game exe sadly.
 
Upvote 0
Ooooh, its a Unity thing then! That makes a whole lot of sense now!

In the meantime I realized that I've been an idiot and I already have a program to get data from VaM - all I needed was to write my own local client where I translate the data and can do with it what I want. So that works now.

Thank you though!
 
Upvote 0
Potentially helpful is the Connect plugin. It uses network sockets to connect to an app running on the same machine or anywhere in the local network. So you could have an app as "relay" that just makes the actual REST calls.
 
Upvote 0
One thing to note: be aware that your plugin will require a specific security setting (as it's sending infos outside). VAM being a software trying to not breach privacy, you'll have to be super transparent about what data you are sending and getting, as people don't like very much to provide data for porn sims ;)
 
Upvote 0
Oh, this is just a private thing and I am not sending the data outside the local network. I got a Lovense Solace Pro recently but I noticed that toolchain I was using to connect it to VaM (ToySerialController+VaMSync) didn't actually set the position. Instead what was supposed to be the position was being translated as strength of thrust. Obviously this was very out of sync with the animation and not really the kind of immersion I was hoping for. And since I'm a C# developer, I figured I might be able to create a solution to that problem (really only for personal use).

I found out that basically, you can skip the entire toolchain you would normally use and could just use a VaM PlugIn to connect to the Lovense App, since it has it's own built-in REST-service. That way you can directly send Json commands to your toys. And instead of writing a whole PlugIn, I was planning on writing an add-on script for the ToySerialController. But that's where I hit the road block that lead to my original post here.

By now, I have abandoned modifying the PlugIn and instead I have written a bridge in C#. Small console program that runs a Udp-Server for ToySerialController to connect to, parses the data relevant for the Solace Pro and pushes it out as Rest requests to the Lovense App. That way I can directly update the position of the toy according to what's happening in VaM.

I'm still in early testing phases, messing around with settings and values, cleaning up the data I receive so I don't overwhelm the network or cause the toy to behave weirdly, but it looks like I am starting to get decent results.
 
Upvote 0
Back
Top Bottom