Module Client : correction d'un bug faisant que le compte utilisateur n'était pas ajouté au message, provoquant le rejet systématique des requêtes

This commit is contained in:
Notmoo-PC\Notmoo 2017-11-03 18:31:14 +01:00
parent c6de9e87a8
commit 5217b6f782
3 changed files with 18 additions and 2 deletions

View File

@ -26,6 +26,8 @@ public class ClientBackEndModuleManager {
statService = new StatService(queryExecutor); statService = new StatService(queryExecutor);
networkService = new NetworkService(queryExecutor, connectionService); networkService = new NetworkService(queryExecutor, connectionService);
queryExecutor.setAccountService(accountService);
networkService.addListener(new INetworkServiceListener() { networkService.addListener(new INetworkServiceListener() {
@Override @Override
public void onPQTPingSuccessEvent(String host, Integer port) { public void onPQTPingSuccessEvent(String host, Integer port) {

View File

@ -1,5 +1,6 @@
package com.pqt.client.module.query; package com.pqt.client.module.query;
import com.pqt.client.module.account.AccountService;
import com.pqt.client.module.connection.ConnectionService; import com.pqt.client.module.connection.ConnectionService;
import com.pqt.client.module.connection.listeners.IConnectionListener; import com.pqt.client.module.connection.listeners.IConnectionListener;
import com.pqt.client.module.query.exceptions.HeaderNotFoundException; import com.pqt.client.module.query.exceptions.HeaderNotFoundException;
@ -29,6 +30,10 @@ public class QueryExecutor {
this.messageFactory = new QueryMessageFactory(messageToolFactory); this.messageFactory = new QueryMessageFactory(messageToolFactory);
} }
public void setAccountService(AccountService accountService){
messageFactory.setAccountService(accountService);
}
public void executeSaleQuery(Sale sale, INoItemMessageCallback callback) { public void executeSaleQuery(Sale sale, INoItemMessageCallback callback) {
sendMessage(messageFactory.newSaleMessage(sale), callback, MessageType.ACK_SALE); sendMessage(messageFactory.newSaleMessage(sale), callback, MessageType.ACK_SALE);
} }

View File

@ -1,5 +1,6 @@
package com.pqt.client.module.query; package com.pqt.client.module.query;
import com.pqt.client.module.account.AccountService;
import com.pqt.core.communication.IMessageToolFactory; import com.pqt.core.communication.IMessageToolFactory;
import com.pqt.core.entities.messages.Message; import com.pqt.core.entities.messages.Message;
import com.pqt.core.entities.messages.MessageType; import com.pqt.core.entities.messages.MessageType;
@ -15,9 +16,15 @@ import java.util.Map;
class QueryMessageFactory { class QueryMessageFactory {
private final IMessageToolFactory messageToolFactory; private final IMessageToolFactory messageToolFactory;
private AccountService accountService;
QueryMessageFactory(IMessageToolFactory messageToolFactory) { QueryMessageFactory(IMessageToolFactory messageToolFactory) {
this.messageToolFactory = messageToolFactory; this.messageToolFactory = messageToolFactory;
accountService = null;
}
void setAccountService(AccountService accountService){
this.accountService = accountService;
} }
Message newSaleMessage(Sale sale) { Message newSaleMessage(Sale sale) {
@ -60,7 +67,9 @@ class QueryMessageFactory {
} }
private Message newSimpleMessage(MessageType type, Map<String, String> fields){ private Message newSimpleMessage(MessageType type, Map<String, String> fields){
return new Message(type, null, null, null, null, fields); //TODO add emitter
Account account = accountService!=null?accountService.getCurrentAccount():null;
return new Message(type, null, null, account, null, fields);
} }
private Message newSimpleMessage(MessageType type){ private Message newSimpleMessage(MessageType type){