#ifndef CLIENT_MESSAGES_H
#define CLIENT_MESSAGES_H

#include <QQueue>
#include <QSettings>
#include <QTcpSocket>
#include "SH_server_base.h"
#include "SH_client_channel.h"
#include "SH_ui_sync.h"
#include "SH_network_types.h"
#include "SH_base.h"

class RemoteClientMessages: public QObject, public PIObject {
	Q_OBJECT
	PIOBJECT(RemoteClientMessages)
public:
	RemoteClientMessages();
	~RemoteClientMessages();

protected:
	void timerEvent(QTimerEvent * e) override;
	EVENT_HANDLER(void, connectedP);
	EVENT_HANDLER(void, disconnectedP);
	EVENT_HANDLER(void, disconnectedPD);
	EVENT_HANDLER1(void, receiveEvent, PIByteArray, data);
	EVENT_HANDLER(void, addressesChangedEvent);
	void messageReceived(const PacketMessage & m);
	void requestLang();

	SHClientChannel channel;
	PIEthernet peth;
	QTcpSocket qeth;
	PacketServerInfo server_info;
	QSettings settings;
	int timer, timer_10s;
#ifdef ANDROID
	PIEthernet interface;

	EVENT_HANDLER2(void, interfaceReceived, THREADED_READ_TYPE, data, ssize_t, size);
	EVENT_HANDLER1(void, interfaceReceivedQ, PIByteArray, ba);
	EVENT1(interfaceReceivedE, PIByteArray, ba);
#endif

private slots:
	void disconn();
	void connect();

public slots:
	void connectedToServer(const PacketServerInfo & si);
	void disconnect();
	
signals:
	void status(QString);
	
};

#endif // CLIENT_MESSAGES_H
