Event and Emit in Solidity

Hope all doing well.
I want to do the following TWO activities in the SOLIDITY code written below:-
An ASAP help will be highly appreciable.
Thanks with regards
Syed

Activities:-

Emit an event ScoreChanged with two arguments: int amount (equal to the value that was sent) and bool direction (true for up function and false for down).

Emit an event GameEnded after gameOver is switched to true

Solidity code:-

pragma solidity ^0.4.17;

contract TugOfWar {

int public score = 0;
int constant endAt = 1 ether;
bool public gameOver = false;

function up() external payable {
    require(msg.value > 0);
    require(!gameOver);

    int value = int(msg.value);
    score += value;

//
checkIfGameOver();
}

function down() external payable {
    require(msg.value > 0);
    require(!gameOver);

    int value = int(msg.value);
    score -= value;

//

    checkIfGameOver();
}

function checkIfGameOver() internal {
    if(score >= endAt || score <= endAt * -1) {
        gameOver = true;

        //
    }
}

}

dnd 5e – If you succeed on the saving throw for the Sickening Radiance spell, do you still take the level of exhaustion and emit the light?

The Sickening Radiance spell says:

When a creature moves into the spell’s area for the first time on a turn or starts its turn there, that creature must succeed on a Constitution saving throw or take 4d10 radiant damage, and it suffers one level of exhaustion and emits a dim, greenish light in a 5-foot radius.

The grammar and punctuation here makes me wonder: do the level of exhaustion and greenish light happen regardless of the result of the saving throw, just like how some spells still deal half damage when you succeed on the save?

I suspect they do. Otherwise it should have been written “…must succeed on a Constitution saving throw or take 4d10 radiant damage, suffer one level of exhaustion, and emit a dim, greenish light…”

java – Socket.io: Can broadcast but cannot emit

I am trying to send messages between two java clients using https://github.com/socketio/socket.io-client-java (v1.0.0). I can broadcast to all channels, but when I try to emit to a single channel, the server does not pass on the messages.

What am I doing wrong?

Server (Version – node v14.15.1 (npm v6.14.8)):

var fs = require('fs');

var options = {
    key: fs.readFileSync('.../privkey.pem'),
    cert: fs.readFileSync('.../fullchain.pem')
};

var app = require('https').createServer(options);
var io = require('socket.io').listen(app);
app.listen(8080);

io.on('connection', socket => {
  
  socket.on('feedback', (data) => {
    console.log("feedback");
    socket.broadcast.emit('feedback', data);
    
    //socket.emit('feedback', data);
  });

});

c++ – QTcpSocket does not emit connected()

I’m using QT5 and starting out with a basic Server/Client setup. I’m looking at going single threaded for both apps as there is no heavy processing on network data. Now, from everything I’ve read and researched here, when using asynchronous approach, you don’t use waitForXXXX() otherwise it messes up all the signals and slots.
The problem – On the client end, the connected() signal is either never emitted or never processed, even though the server consoles tells me that a new client has connected. I’ve been working on the same issue for 2 weeks now and couldn’t find the exact same issue anywhere. I’ve stripped back both apps to the minimum and still no luck – also stripped out the UI part now – I just want see the console working. I have also tried switching to public slots and changing the signal/slot connection type and still have the same problem.

If you require code from the server, please let me know, but here is the basics of the client:

main.cpp

#include "QGameSocket.h"
#include <QtWidgets/QApplication>

#include <windows.h>

int main(int argc, char *argv())
{
    AllocConsole();
    freopen( "conin$", "r", stdin );
    freopen( "conout$", "w", stdout );
    freopen( "conout$", "w", stderr );

    QApplication a( argc, argv );
    QGameSocket* pSocket = new QGameSocket();

    return a.exec();
}

QGameSocket.h

#ifndef _QGAMESOCKET_H
#define _QGAMESOCKET_H

#include <QtNetwork/qtcpsocket.h>
#pragma comment ( lib, "Qt5Network.lib" )

class QGameSocket: public QObject
{
    Q_OBJECT

public:
    explicit QGameSocket( QObject* pParent = 0 );
    ~QGameSocket();

private slots:
    void __OnConnected();
    void __OnReadyRead();

private:
    QTcpSocket* m_pSocket;
};

#endif

QGameSocket.cpp

#include "QGameSocket.h"
#include <qdatastream.h>

QGameSocket::QGameSocket( QObject* pParent ) :  
    QObject( pParent )
{
    m_pSocket = new QTcpSocket();
    
    connect( m_pSocket, SIGNAL( connected() ), this, SLOT( __OnConnected() ) );
    connect( m_pSocket, SIGNAL( readyRead() ), this, SLOT( __OnReadyRead() ) );

    const QString strHost = "127.0.0.1";

    qDebug() << "Connecting to host ...";
    m_pSocket->connectToHost( strHost, 27015 );
}

QGameSocket::~QGameSocket()
{
    m_pSocket->deleteLater();
}

void QGameSocket::__OnConnected()
{
    qDebug() << "Successfully connected to host!";
}

void QGameSocket::__OnReadyRead()
{
    //handle messages
}

Any help would be much appreciated, thank you!

web development – Is it better to transfer data through sockets, or just emit the information that the data has been changed?

I’m building a game lobby and I have two cases:

  1. When creating a new room, send the room data to the server via sockets. Then, the server stores the data in the database and emit that data to all client sockets connected in the lobby.

or

  1. When creating a new room, send the room data to the server via sockets. The server then stores the data in the database and emits the information that there are new rooms for all client sockets connected in the lobby. The clients then, upon receiving this information, make a request to graphql api about the new rooms created.

What would be the best option in terms of bandwidth usage, server usage, reliability, scalability, etc.?

Does the ISO setting on the back of the flash emit less light at higher ISO settings?

I am using an old Minolta Auto 25 flash camera that is wirelessly connected to my FUJI XT2. There is no manual power switch, just an ISO dial. I don't want to use auto mode, but I don't want to increase the distance between the flash and the subject to reduce the light intensity. So if I set the ISO dial for the flash to 800, does the flash emit less light / power than if it were set to the same ISO setting as the camera, in this case 100?
In other words, when the camera ISO is set to 800, the sensor becomes more sensitive to light. So if I set the ISO on the flash to 800 and the camera to 100, it will deceive the flash to emit less light because I believe that if the camera setting was 800 it would give the camera enough light. Angry..

Bose Revolve Soundlink USB does not emit sound

I'm trying to get my Bose Revolve soundlink up and running via USB (Bluetooth and AUX are working fine). The use of USB on Windows also works well.

The speakers are well recognized, but when I switch to the right output device, no sound is heard.

I have two output profiles to switch between pavucontrol: "Analog Stero" and "Digital Stero (IEC958)". None of them works.

$ cat / proc / asound / cards
0 [NVidia         ]: HDA-Intel - HDA-NVidia
HDA NVidia at 0xf7080000 irq 67
1 [Generic        ]: HDA-Intel - Generic HD Audio
HD Audio Generic at 0xf7700000 irq 69
2 [SoundLink      ]: USB Audio - Bose Revolve SoundLink
Bose Corporation Bose Revolve SoundLink at usb-0000: 02: 00-0-10, at full speed

from dmesg:

[ 5287.800381]    USB 1-10: New full-speed USB device # 10 with xhci_hcd
[ 5288.137063] usb 1-10: New USB device found, idVendor = 05a7, idProduct = 40fa
[ 5288.137067] USB 1-10: New USB device strings: Mfr = 1, Product = 2, SerialNumber = 3
[ 5288.137069] USB 1-10: Product: Bose Revolve SoundLink
[ 5288.137072] usb 1-10: Manufacturer: Bose Corporation
[ 5288.137074] usb 1-10: serial number: Q73160860107429561A0210
[ 5288.197492] Input: Bose Corporation Bose Revolve SoundLink as /devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-10/1-10:1.2/0003:05A7:40FA.0009/input/input36

from lsusb

Bus 001 Device 010: ID 05a7: 40fa Bose Corp.
Device could not be opened, some information is missing
Device Description:
length 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Other device
bDeviceSubClass 2?
bDeviceProtocol 1 interface assignment
bMaxPacketSize0 64
idVendor 0x05a7 Bose Corp.
idProduct 0x40fa
bcdDevice 1.00
Manufacturer 1
iProduct 2
iSerial 3
bNumConfigurations 1
Configuration description:
length 9
bDescriptorType 2
wTotalLength 156
bNumInterfaces 3
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
self-Powered
MaxPower 500mA
Interface Association:
length 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 1 Audio
bFunctionSubClass 1 controller
bFunctionProtocol 0
iFunction 0
interface descriptor:
length 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 1 controller
bInterfaceProtocol 0
iInterface 0
AudioControl Interface Descriptor:
length 9
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdADC 1.00
wTotalLength 43
bInCollection 1
baInterfaceNr (0) 1
AudioControl Interface Descriptor:
length 12
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0101 USB streaming
bAssocTerminal 0
bNrChannels 2
wChannelConfig 0x0003
Left front (L)
Right front (R)
iChannelNames 0
iTerminal 0
AudioControl Interface Descriptor:
length 13
bDescriptorType 36
bDescriptorSubtype 6 (FEATURE_UNIT)
bUnitID 2
bSourceID 1
bControlSize 2
bmaControls (0) 0x03
bmaControls (0) 0x00
mute
Volume Control
bmaControls (1) 0x00
bmaControls (1) 0x00
bmaControls (2) 0x00
bmaControls (2) 0x00
iFeature 0
AudioControl Interface Descriptor:
length 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 3
wTerminalType 0x0301 speaker
bAssocTerminal 0
bSourceID 2
iTerminal 0
interface descriptor:
length 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
interface descriptor:
length 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
Audio streaming interface descriptor:
length 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 1
bDelay 0 frames
wFormatTag 1 PCM
Audio streaming interface descriptor:
length 14
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 2
bSubframeSize 2
bBitResolution 16
bSamFreqType 2 Discrete
tSamFreq[ 0]        48000
tSamFreq[ 1]        44100
AudioControl Endpoint Descriptor:
length 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x81
sampling
MaxPacketsNur
bLockDelayUnits 0 Not defined
wLockDelay 0 Not defined
Endpoint Description:
length 9
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 1
Transmission type isochronous
Sync Type None
Usage data
wMaxPacketSize 0x00c0 1x 192 bytes
bInterval 1
bRefresh 0
bSynchAddress 0
interface descriptor:
length 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0 No subclass
bInterfaceProtocol 0 None
iInterface 0
HID devices Description:
length 9
bDescriptorType 33
bcdHID 1.11
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 126
Berichtsdeskriptoren:
** NOT AVAILABLE **
Endpoint Description:
length 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transmission type interrupt
Sync Type None
Usage data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
Endpoint Description:
length 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 3
Transmission type interrupt
Sync Type None
Usage data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1

I tried a restart.

Every help is appreciated.