Question Someone know whats wrong?

Currently, I’m exploring web development to see what all the hype is about. Except for following a small ‘create your first CRUD app in Node.JS’ and some formal training in JavaScript, I have no experience.

I’m new to JavaScript, NodeJS, Sails.JS, and WebSockets.

My current problem is this:
The app I’m trying to develop receives POST calls with a JSON object. This is the input part of the application. These POST calls originate from any random host.
The output is a webpage that updates itself by listening on a Sails.JS powered WebSocket system called sails.io.js.
Basically, each POST from any host should result in an event on the WebSocket.
Since I’m not building a formal REST API, I have to define some parts myself in Sails.JS. I do have blueprints enabled.
First, in the controller that handles the POST call, I can call the code below so existing WebSockets can receive an event of a new ServiceHeartBeatSession being created. All the server side code mentioned here is located in the controller or executed in the console.

Code:
sails.sockets.addRoomMembersToRooms(ServiceHeartBeatSession._classRoom()
, ServiceHeartBeatSession._room(session.id) );
Then, the invoke method is executed to send this event to all listening WebSockets.
ServiceHeartBeatSession.publish([ session.id ], { "verb": "created" });
However, the .publish method does not result in a event to an existing WebSocket. Unless I execute it myself in the console. The WebSocket is registered like this:
[COLOR=var(--tertiary-high)]io[/COLOR].socket.on([COLOR=var(--hljs-string)]'serviceheartbeatsession'[/COLOR], [COLOR=var(--primary-very-high)]function[/COLOR](resData) {
alert([COLOR=var(--hljs-string)]'Something changed!!!!'[/COLOR]);
});

I did some digging into the sourcecode and made some attempts at debugging this myself. Here’s what I’ve found so far:

  • Running the .publish call in the console produces the desired result.
  • It appears that the .addRoomMembersToRooms is a requirement for the .publish to work in the console. So I’m assuming that .addRoomMembersToRooms works as intended.
  • I tried the alternative below, but that doesn’t work in the controller. However, it does work in the Node console.

sails.sockets.broadcast([ ServiceHeartBeatSession._room(session.id) ], "serviceheartbeatsession", 'hi!');

  • The following works as intended, but I prefer not to use that.

sails.io.sockets.emit('serviceheartbeatsession', { verb: 'created' });

  • The above attempt lacked a room selection, so I dug a little deeper. The calls below where the result of a .publish method. However, only after repeating this in the console, it worked.
    var emitter = sails.io.sockets;
    emitter.in(‘sails_model_serviceheartbeatsession_5b6b26748377829d34983d67:serviceheartbeatsession’); // for example
    emitter.emit(‘serviceheartbeatsession’, { verb: “created” });

Check more information in the article: How to Build Node.js APIs with Sails.js | Adeva
Anyone have any ideas?

  • Solved
Solved How to make bluetooth smooth on Linux?

All of the devices like windows/ android when my headphones/ Bluetooth keyboard go to sleep after being inactive for some time, they don't reconnect automatically. Even If I go manually in the bluetooth settings, It doesn't work sometimes I need to forget the device, and re-scan and reconnect.
While on windows/ android/ mac it just reconnects as soon as I type some key on my keyboard.

Question How to specify which session in tigervnc on Arch?

I installed tigervnc using
Code:
sudo pacman -S tigervnc

I did set password using
Code:
vncpasswd



Here are my configs in $HOME/.vnc

Code:
breadpitt% cat ~/.vnc/config
session=cinnamon-session-cinnamon
geometry=1920x1080
localhost
alwaysshared


breadpitt% cat ~/.vnc/xstartup
#!/bin/sh
exec env GNOME_SHELL_SESSION_MODE=classic gnome-session
breadpitt%

I have no idea why running vncserver :1 opens an awesome wm session instead of cinnamon or gnome specified in those configs.

Looking For Best Mouse For Valorant?

If you are looking for the best mouse for valorant, I may help you with it. I am gonna include some mice because only one can't best. Some of the mice are better by their build quality, Also some of chosen by some pro gamers, Also some by people of different sizes of hands.

So here are some of the best mice that work great for you & valorant.

DX9.0c not supported on Windown 10?

Does anyone know if it's possible to have Forza Horizon 3 show up in the Volume Mixer within Windows? I usually like to balance audio output from programs but unfortunately every time I want to change the volume I have to dig through the settings and flip back and forth between the game and what I'm listening to in order to have it work the way I want...


1b4346f1ff3a58b8b8c0aca2f52a3a45.png

Filter