Skip to content

Commit

Permalink
added flag to allow socket.io to use polling/xhr if a ws connection c…
Browse files Browse the repository at this point in the history
…annot be establish
  • Loading branch information
oznu committed Apr 19, 2019
1 parent bc06613 commit 1be58ee
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 100 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/).

## 4.0.2 (2019-04-19)

### Notable Changes

* Added `websocketCompatibilityMode` option for users who are having issues with WebSocket connections ([#238](https://github.com/oznu/homebridge-config-ui-x/pull/238))

### Other Changes

* Updated npm dependencies

## 4.0.1 (2019-04-17)

### Bug Fixes
Expand Down
4 changes: 4 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@
"title": "Tell Homebridge the plugin is operating in standalone mode",
"type": "boolean"
},
"websocketCompatibilityMode": {
"title": "Run the web socket connection in compatibility mode",
"type": "boolean"
},
"sessionTimeout": {
"title": "Session timeout in seconds",
"type": "integer"
Expand Down
173 changes: 86 additions & 87 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homebridge-config-ui-x",
"version": "4.0.1",
"version": "4.0.2",
"description": "Configuration UI plugin for Homebridge",
"license": "MIT",
"author": "oznu <[email protected]>",
Expand Down Expand Up @@ -57,13 +57,13 @@
"@oznu/hap-client": "0.0.4",
"@types/express": "^4.16.0",
"@types/fs-extra": "^5.0.5",
"@types/node": "^11.13.4",
"@types/node": "^11.13.5",
"@types/socket.io": "^2.1.2",
"bash-color": "0.0.4",
"buffer-shims": "^1.0.0",
"concurrently": "^4.1.0",
"dotenv": "^7.0.0",
"fastify": "^2.2.0",
"fastify": "^2.3.0",
"fastify-static": "^2.4.0",
"fs-extra": "^7.0.1",
"helmet": "^3.16.0",
Expand All @@ -72,7 +72,7 @@
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"pino-pretty": "^2.6.0",
"point-of-view": "^3.1.1",
"point-of-view": "^3.2.0",
"prettier": "^1.17.0",
"qr-image": "^3.2.0",
"request": "^2.88.0",
Expand All @@ -81,10 +81,10 @@
"ts-loader": "^5.3.3",
"ts-node": "^8.1.0",
"tsconfig-paths": "^3.5.0",
"tslint": "^5.15.0",
"typescript": "^3.4.3",
"tslint": "^5.16.0",
"typescript": "^3.4.4",
"webpack": "^4.30.0",
"webpack-cli": "^3.3.0",
"webpack-node-externals": "^1.7.2"
}
}
}
2 changes: 2 additions & 0 deletions src/core/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class ConfigService {
};
proxyHost?: string;
sessionTimeout?: number;
websocketCompatibilityMode?: boolean;
};

public secrets: {
Expand Down Expand Up @@ -120,6 +121,7 @@ export class ConfigService {
runningInDocker: this.runningInDocker,
runningInLinux: this.runningInLinux,
temperatureUnits: this.ui.tempUnits || 'c',
websocketCompatibilityMode: this.ui.websocketCompatibilityMode || false,
},
formAuth: Boolean(this.ui.auth !== 'none'),
theme: this.ui.theme || 'teal',
Expand Down
10 changes: 5 additions & 5 deletions ui/src/app/core/auth/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ export class AuthGuard implements CanActivate {
async canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): | Promise<boolean> {
// ensure app settings are loaded
if (!this.$auth.settingsLoaded) {
await this.$auth.getAppSettings();
}

if (this.$auth.isLoggedIn()) {
return true;
} else {
// ensure app settings are loaded
if (!this.$auth.settingsLoaded) {
await this.$auth.getAppSettings();
}

// if using not using auth, get a token
if (this.$auth.formAuth === false) {
await this.$auth.noauth();
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/core/ws.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class WsService {
*/
private establishConnectionToNamespace(namespace: string): IoNamespace {
const socket: SocketIOClient.Socket = connect(`${environment.api.socket}/${namespace}`, {
transports: ['websocket'],
transports: this.$auth.env.websocketCompatibilityMode ? undefined : ['websocket'],
query: {
token: this.$auth.token,
},
Expand Down

0 comments on commit 1be58ee

Please sign in to comment.