2014-09-17 16:43:05 +03:00
|
|
|
#include "interface/event.h"
|
|
|
|
|
|
|
|
namespace network
|
|
|
|
{
|
|
|
|
struct PeerInfo
|
|
|
|
{
|
|
|
|
typedef size_t Id;
|
2014-09-17 20:15:46 +03:00
|
|
|
|
2014-09-17 16:43:05 +03:00
|
|
|
Id id = 0;
|
|
|
|
ss_ address;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Packet: public interface::Event::Private
|
|
|
|
{
|
|
|
|
typedef size_t Type;
|
2014-09-17 20:15:46 +03:00
|
|
|
|
2014-09-17 20:24:06 +03:00
|
|
|
PeerInfo::Id recipient;
|
2014-09-17 20:49:30 +03:00
|
|
|
Type type; // TODO: Allow supplying a name directly here alternatively
|
2014-09-17 16:43:05 +03:00
|
|
|
ss_ data;
|
|
|
|
|
2014-09-17 20:24:06 +03:00
|
|
|
Packet(PeerInfo::Id recipient, const Type &type, const ss_ &data):
|
|
|
|
recipient(recipient), type(type), data(data){}
|
2014-09-17 16:43:05 +03:00
|
|
|
};
|
|
|
|
|
2014-09-17 20:24:06 +03:00
|
|
|
struct NewClient: public interface::Event::Private
|
2014-09-17 16:43:05 +03:00
|
|
|
{
|
2014-09-17 20:15:46 +03:00
|
|
|
PeerInfo info;
|
|
|
|
|
2014-09-17 20:24:06 +03:00
|
|
|
NewClient(const PeerInfo &info): info(info){}
|
2014-09-17 20:15:46 +03:00
|
|
|
};
|
2014-09-17 20:49:30 +03:00
|
|
|
|
|
|
|
struct Req_get_packet_type: public interface::Event::Private
|
|
|
|
{
|
|
|
|
ss_ name;
|
|
|
|
|
|
|
|
Req_get_packet_type(const ss_ &name): name(name){}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Resp_get_packet_type: public interface::Event::Private
|
|
|
|
{
|
|
|
|
Packet::Type type;
|
|
|
|
|
|
|
|
Resp_get_packet_type(const Packet::Type &type): type(type){}
|
|
|
|
};
|
2014-09-17 23:00:31 +03:00
|
|
|
|
|
|
|
struct Direct
|
|
|
|
{
|
|
|
|
virtual ~Direct(){}
|
|
|
|
virtual Packet::Type packet_type(const ss_ &name) = 0;
|
|
|
|
virtual void send(PeerInfo::Id recipient, const Packet::Type &type,
|
2014-09-17 23:05:05 +03:00
|
|
|
const ss_ &data) = 0;
|
2014-09-17 23:00:31 +03:00
|
|
|
};
|
2014-09-17 16:43:05 +03:00
|
|
|
}
|
|
|
|
|