{"id":20081263,"url":"https://github.com/depuits/mpd-server","last_synced_at":"2025-03-02T13:25:46.998Z","repository":{"id":57303529,"uuid":"123902541","full_name":"depuits/mpd-server","owner":"depuits","description":"Node js mpd server.","archived":false,"fork":false,"pushed_at":"2020-11-10T14:12:25.000Z","size":18,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T07:44:18.008Z","etag":null,"topics":["listen","mpd-server","nodejs","protocol","subsystem"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/depuits.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-05T10:20:39.000Z","updated_at":"2023-01-15T09:55:18.000Z","dependencies_parsed_at":"2022-08-24T17:11:20.055Z","dependency_job_id":null,"html_url":"https://github.com/depuits/mpd-server","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depuits%2Fmpd-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depuits%2Fmpd-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depuits%2Fmpd-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depuits%2Fmpd-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/depuits","download_url":"https://codeload.github.com/depuits/mpd-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241511679,"owners_count":19974443,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["listen","mpd-server","nodejs","protocol","subsystem"],"created_at":"2024-11-13T15:34:06.686Z","updated_at":"2025-03-02T13:25:46.979Z","avatar_url":"https://github.com/depuits.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MPD-server\n\nA node js implementation of the [MPD protocol](https://www.musicpd.org/doc/protocol/). This library should make it easier to implement this protocol in your applications.\n\n## Getting Started\n\n### Installing\n\n```\nnpm i mpd-server\n```\n\n### Usage\n\n```javascript\n'use strict';\n// returns a function to create a mpd-server object\n// this function expects a commandHandler function.\nconst mpd = require('mpd-server');\n\n// The commandHandler function gets the command, arguments and connection from which it is requested.\n// It needs to return an promise which returns a string value\nfunction handleCommand(cmd, params, con) {\n\t// the idle is handled internally and does not go through here\n\tconsole.log('Command: ' + cmd);\n\treturn Promise.resolve('command response');\n}\n\n// create the mpd server given the function which will handle the commands\nconst mpdServer = mpd(handleCommand);\n\n// start listening for connections\nmpdServer.listen({ port: 6600 }, () =\u003e {\n\tconsole.log('mpd running on ', mpdServer.server.address());\n});\n\n// register any callback your interested in\nmpdServer.on('error', (err, s) =\u003e { console.log(err); });\n\n// call this when a subsystem changes to notify the clients\nserver.systemUpdate('subsystem');\n```\n\n#### Server\n\n##### Methods\n\n- **constructor** *(cmdHandler)*\n\nConstructor of hte mpd server. The command handler function is responsible to handle all [commands](https://www.musicpd.org/doc/html/protocol.html#command-reference) send by the clients. The only exception here is the `idle`. This command is handled internally. This function must return a promise which resolves to the response for the client.\n\n- **listen** *(options)*\n\nStart listening for clients. The options are passed to the [server listen](https://nodejs.org/api/net.html#net_server_listen_options_callback).\n\n- **systemUpdate** *(subsystem)*\n\nNotify a subsystem update.\n\n##### Events\n- **connect** *(connection)*\n- **disconnect** *(connection)*\n- **error** *(error, connection)*\n\n##### Objects\n- server: [net.Server](https://nodejs.org/api/net.html#net_class_net_server)\n- connections: [Connection](https://github.com/depuits/mpd-server#connection)[]\n\n#### Connection\n\n##### Events\n- **connect** *(connection)*\n- **disconnect** *(connection)*\n- **idle** *(connection)*\n\nEmitted when the connection is going in to idle mode as describe [here](https://www.musicpd.org/doc/html/protocol.html#querying-mpd-s-status).\n\n- **noidle** *(connection)*\n\nEmitted when the connection exits the idle mode.\n\n- **error** *(error, connection)*\n\nEmitted on socket error event. \n\n- **commanderror** *(error, connection, errorAck)*\n\nEmitted when a command handler failed. The third parameter is the error  response as described in the [protocol](https://www.musicpd.org/doc/html/protocol.html#failure-responses).\n\n- **system** *(subsystem, connection)*\n\nEmitted when a subsytem update is send.\n\n##### Objects\n- socket: [net.Socket](https://nodejs.org/api/net.html#net_class_net_socket)\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/depuits/mpd-server/tags). \n\n## License\n\nThis project is licensed under the Apache License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdepuits%2Fmpd-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdepuits%2Fmpd-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdepuits%2Fmpd-server/lists"}