Skip to content

Commit

Permalink
update core dependencies and use new socket service
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Jun 13, 2023
1 parent 1ca718f commit c6c4f4e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 32 deletions.
33 changes: 19 additions & 14 deletions addon/controllers/sockets/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { isBlank } from '@ember/utils';
import { format } from 'date-fns';
import config from 'ember-get-config';

export default class SocketsViewController extends Controller {
/**
* Inject the router service
* Inject the `router` service
*
* @var {Service}
*/
@service hostRouter;

/**
* Inject the `socket` service
*
* @var {Service}
*/
@service socket;

/**
* Incoming events logged from socket
*
Expand All @@ -30,24 +35,24 @@ export default class SocketsViewController extends Controller {
return window.history.back();
}

createSocketClusterClient() {
const socketConfig = { ...config.socket };

if (isBlank(socketConfig.hostname)) {
socketConfig.hostname = window.location.hostname;
}

return socketClusterClient.create(socketConfig);
}

/**
* Opens socket and logs all incoming events.
*
* @memberof SocketsViewController
*/
@action async watchSocket(model) {
/**
@todo make this work later
this.socket.listen(model.name, ({ data }) => {
this.events.pushObject({
time: format(new Date(), 'PPPP'),
content: JSON.stringify(data, undefined, 2),
});
});
**/

// create socketcluster client
const socket = this.createSocketClusterClient();
const socket = this.socket.instance();

// listen on company channel
const channel = socket.subscribe(model.name);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@fleetbase/dev-engine",
"extension": "Developers",
"icon": "code",
"version": "0.0.7",
"version": "0.0.8",
"priority": 2,
"description": "Fleetbase Developers extension provides a module for managing developer resources such as API keys, webhooks, sockets, events and logs.",
"keywords": [
Expand Down Expand Up @@ -36,8 +36,8 @@
"test:ember-compatibility": "ember try:each"
},
"dependencies": {
"@fleetbase/ember-core": "^0.0.3",
"@fleetbase/ember-ui": "^0.0.6",
"@fleetbase/ember-core": "^0.0.4",
"@fleetbase/ember-ui": "^0.0.7",
"@fortawesome/ember-fontawesome": "^0.4.1",
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.4.0",
Expand Down
39 changes: 24 additions & 15 deletions pnpm-lock.yaml

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

0 comments on commit c6c4f4e

Please sign in to comment.