mpp-client-xt
v1.3.1
Published
MPP Client Extended
Downloads
32
Maintainers
Readme
mpp-client-xt
is a modified version of the official mpp-client
package to make it more useful and easier to use. The changes are as follows:
- Module variables are properly prefixed with
var
instead of assigning to the global object. - URI argument now defaults to
wss://www.multiplayerpiano.com
so you don't have to pass any arguments if you're using it with that. - Proxy support - Add an https or socks proxy url as the second argument to the constructor.
- WebSocket binary type set to "arraybuffer" to support ming's alternative server with binary note data extension.
- WebSocket errors are emitted from the Client as "error" events to comply with standard Node.js practices and allow you to handle the errors your way. Note that "error" events stop the processes if there are no listeners so make sure to add an "error" listener if you want the client to reconnect instead of shutting down the process.
- WebSocket message parser only parses strings now (so it won't crash with binary note data) and parsing errors are caught and emitted in the "error" event (again make sure to add an "error" listener).
- A bunch of extra methods have been added to make the client easier to use. Now you can just
client.say("meow")
instead ofclient.sendArray([m:'a',message:"meow"])
!
Example Usage
var MPPclient = require("mpp-client-xt")
var mppClient = new MPPclient()
mppClient.setChannel("test/awkward")
mppClient.start()
mppClient.on("hi", () => mppClient.userset({name: "foo"})
mppClient.on("a", msg => {
if (msg.a == "foo") mppClient.say("bar")
})
For more information just look at the code!