Skip to content

Commit 6cde896

Browse files
authored
Clarify readme example
1 parent 3648239 commit 6cde896

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,18 @@ open('My SimConnect client', Protocol.FSX_SP2)
3737
.then(function ({ recvOpen, handle }) {
3838
console.log('Connected to', recvOpen.applicationName);
3939

40+
// 1. Subscribe for pause event
41+
handle.subscribeToSystemEvent(EVENT_ID_PAUSE, 'Pause');
42+
43+
// 2. Handle pause event
4044
handle.on('event', function (recvEvent) {
4145
switch (recvEvent.clientEventId) {
4246
case EVENT_ID_PAUSE:
4347
console.log(recvEvent.data === 1 ? 'Sim paused' : 'Sim unpaused');
4448
break;
4549
}
4650
});
51+
4752
handle.on('exception', function (recvException) {
4853
console.log(recvException);
4954
});
@@ -54,7 +59,6 @@ open('My SimConnect client', Protocol.FSX_SP2)
5459
console.log('Connection closed unexpectedly (simulator CTD?)');
5560
});
5661

57-
handle.subscribeToSystemEvent(EVENT_ID_PAUSE, 'Pause');
5862
})
5963
.catch(function (error) {
6064
console.log('Connection failed:', error);

0 commit comments

Comments
 (0)