mpp-client-xt

1.3.1 • Public • Published

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 of client.sendArray([m:'a',message:"meow"])!
    • Screenshot of extra methods

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!

/mpp-client-xt/

    Package Sidebar

    Install

    npm i mpp-client-xt

    Weekly Downloads

    8

    Version

    1.3.1

    License

    none

    Unpacked Size

    12.5 kB

    Total Files

    3

    Last publish

    Collaborators

    • ledlamp