Skip to main content

Connectors

The first thing to do when writing a Buttplug application is figuring out how to talk to a Buttplug Server (like Intiface Central). For sake of simplicity, we'll cover websockets in this part of the manual, as this is by far the most common method of connecting clients and servers. Other connection situations and solutions (WebRTC, iroh, etc...) are covered in the cookbook section.

Websocket Connectors

Websockets are the default connector transport for Buttplug. They work as both a transport for desktop applications and web browsers, and have implementations available in most programming popular languages. As the library does not send many messages (maybe 50 per second in busy cases), the overhead of websockets isn't really an issue for the library.

Client implementations made by the Buttplug Core Team will provide a websocket connector for you. You should be able to create the connector, define the server address, and use that to connect. For using Websocket servers, you'll need to provide the user a way to pass in the server address (as this will not always exist on the same machine your software is running on), then you just create the connector object using that address.

The Accidental Standard Port of 12345

When Buttplug's first public server came out in 2017, it used port 12345 as a test value. This stuck with the system, so now most applications that use Intiface or Buttplug use port 12345 for connection by default. Some client applications have gone as far as to hardcore the value, but this is not recommended.

This can sometimes be an issue for users running certain software that collides with the port. We have some recommended fixes in the Intiface Central Documentation.

use buttplug::{
client::ButtplugClient,
core::{
connector::{ButtplugRemoteConnector, ButtplugWebsocketClientTransport, new_json_ws_client_connector},
message::serializer::ButtplugClientJSONSerializer,
},
};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
// To create a Websocket Connector, you need the websocket address and some generics fuckery.
let connector = new_json_ws_client_connector("ws://192.168.123.103:12345/buttplug");

let client = ButtplugClient::new("Example Client");
client.connect(connector).await?;

Ok(())
}

Security Considerations

Due to basically being impossible to deal with, Intiface Engine/Central does not implement SSL websockets (wss). This required self-signed certificates which rarely worked correctly and caused end-user confusion. Non-secured websockets work for Intiface Central instances running on the same host as web apps, due to localhost security exceptions. Remote browser connections (i.e. browser on desktop, intiface central on phone) may fail due to security requirements. Intiface Central provides a Repeater Mode (basically a proxy) to work with instances where web browsers on a machine other than the Intiface Central is accessing hardware.