mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-22 01:43:29 +01:00
When running bonob outside of sonos network ability to register with sonos using remote bonob
This commit is contained in:
19
src/registrar.ts
Normal file
19
src/registrar.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import axios from "axios";
|
||||
import logger from "./logger";
|
||||
import sonos, { bonobService } from "./sonos";
|
||||
import { URLBuilder } from "./url_builder";
|
||||
|
||||
export default (bonobUrl: URLBuilder) => async () => {
|
||||
const about = bonobUrl.append({ pathname: "/about" });
|
||||
logger.info(`Fetching bonob service about from ${about}`);
|
||||
return axios
|
||||
.get(about.href())
|
||||
.then((res) => {
|
||||
if (res.status == 200) return res.data;
|
||||
else throw `Unexpected response status ${res.status} from ${about}`;
|
||||
})
|
||||
.then((about) =>
|
||||
bonobService(about.service.name, about.service.sid, bonobUrl)
|
||||
)
|
||||
.then((bonobService) => sonos(true).register(bonobService));
|
||||
};
|
||||
Reference in New Issue
Block a user