Fixed network message ids to be properly passed between server requests and client responses

This commit is contained in:
Jordan Sherer 2019-02-01 12:07:15 -05:00
parent fab53920b9
commit 3ce2ceba34
2 changed files with 13 additions and 8 deletions

View File

@ -11048,6 +11048,8 @@ void MainWindow::networkMessage(Message const &message)
return;
}
qDebug() << "try processing network message" << type;
auto params = message.params();
auto id = params.value("_ID", QVariant(0));
@ -11230,6 +11232,7 @@ void MainWindow::networkMessage(Message const &message)
if(type == "WINDOW.RAISE"){
setWindowState(Qt::WindowActive);
activateWindow();
raise();
return;
}

18
udp.py
View File

@ -1,7 +1,8 @@
from __future__ import print_function
import json
from socket import socket, AF_INET, SOCK_DGRAM
import json
import time
listen = ('127.0.0.1', 2237)
@ -37,13 +38,10 @@ class Server(object):
if params:
print('-> params: ', params)
#### if typ == 'PING':
#### if self.first:
#### self.send('RX.GET_BAND_ACTIVITY')
#### self.send('TX.SET_TEXT', 'HERE WE GO')
#### time.sleep(1)
#### self.send('WINDOW.RAISE')
#### self.first = False
if typ == 'PING':
if self.first:
self.send('STATION.GET_CALLSIGN')
self.first = False
#### if typ == 'PING':
#### self.send('STATION.GET_GRID')
@ -64,6 +62,10 @@ class Server(object):
self.close()
def send(self, *args, **kwargs):
params = kwargs.get('params', {})
if '_ID' not in params:
params['_ID'] = int(time.time()*1000)
kwargs['params'] = params
message = to_message(*args, **kwargs)
print('outgoing message:', message)
self.sock.sendto(message, self.reply_to)