summaryrefslogtreecommitdiff
path: root/plugins/websocket/websocketsinkmanager.h
blob: 1b2fba644a4d3236efce27963bd6f9752070a996 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
	Copyright (C) 2012  Intel Corporation

	This library is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public
	License as published by the Free Software Foundation; either
	version 2.1 of the License, or (at your option) any later version.

	This library is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
	Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public
	License along with this library; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

#ifndef WEBSOCKETSINKMANAGER_H
#define WEBSOCKETSINKMANAGER_H

#include <abstractroutingengine.h>
#include <abstractsink.h>
#include "websocketsink.h"
#include <gio/gio.h>
#include <map>
#include <libwebsockets.h>
#include "debugout.h"
#include <stdexcept>
#include "sys/types.h"
#include <stdlib.h>
#include <QByteArray>

class WebSocketSinkManager
{
public:
	WebSocketSinkManager(AbstractRoutingEngine* engine, map<string, string> config);
	void addSingleShotSink(libwebsocket* socket, VehicleProperty::Property property, Zone::Type zone, string id);
	void addSingleShotRangedSink(libwebsocket* socket, PropertyList properties,double start, double end, double seqstart,double seqend, string id);
	void addSink(libwebsocket* socket, VehicleProperty::Property property, string uuid);
	void disconnectAll(libwebsocket* socket);
	void removeSink(libwebsocket* socket, VehicleProperty::Property property, string uuid);
	void addPoll(int fd);
	void removePoll(int fd);
	void init();
	std::map<std::string, list<WebSocketSink*> > m_sinkMap;
	void setConfiguration(map<string, string> config);
	void setValue(libwebsocket* socket,VehicleProperty::Property property, string value, Zone::Type zone, string uuid);
	PropertyList getSupportedProperties();

	AbstractRoutingEngine * router() { return routingEngine; }

	int partialMessageIndex;
	QByteArray incompleteMessage;
	int expectedMessageFrames;

private:
	std::map<int, GIOChannel*> m_ioChannelMap;
	std::map<int, guint> m_ioSourceMap;
	AbstractRoutingEngine *m_engine;
	struct libwebsocket_protocols protocollist[2];

	AbstractRoutingEngine * routingEngine;
	std::map<std::string, std::string> configuration;

};

#endif // WEBSOCKETSINKMANAGER_H