IPlugin.h
1 #pragma once
2 
3 #include "stormancer/BuildConfig.h"
5 #include "stormancer/Tasks.h"
6 #include <map>
7 #include <memory>
8 #include <sstream>
9 
10 namespace Stormancer
11 {
12  class IClient;
13  class Scene;
14  class ITransport;
15  class IConnection;
16  struct SceneAddress;
17  struct Federation;
18  class Configuration;
19 
20  template<typename T>
21  class Packet;
22 
24  {
25  std::string name = "UnknowPlugin";
26  std::string version = "0.0.0";
27 
28  PluginDescription() = default;
29 
30  PluginDescription(const std::string& name);
31 
32  PluginDescription(const std::string& name, const std::string& version);
33 
34  operator std::string() const;
35 
36  std::string toString() const;
37  };
38 
39  class IPlugin
40  {
41  public:
42 
43 #pragma region public_methods
44 
45  virtual ~IPlugin() = default;
46 
47  virtual PluginDescription getDescription() = 0;
48 
49  virtual void registerClientDependencies(ContainerBuilder& clientBuilder);
50  virtual void clientCreated(std::shared_ptr<IClient> client);
51  virtual void clientDisconnecting(std::shared_ptr<IClient> client);
52  virtual void registerSceneDependencies(ContainerBuilder& sceneBuilder, std::shared_ptr<Scene> scene);
53  virtual void networkAccessRequested(std::shared_ptr<IClient> client);
54  virtual void transportConnecting(std::shared_ptr<IClient> client, std::shared_ptr<ITransport> transport);
55  virtual void transportStarted(std::shared_ptr<ITransport> transport);
56  virtual void packetReceived(std::shared_ptr<Packet<IConnection>> packet);
57  virtual void sceneCreated(std::shared_ptr<Scene> scene);
58  virtual void sceneConnecting(std::shared_ptr<Scene> scene);
59  virtual void sceneConnected(std::shared_ptr<Scene> scene);
60  virtual void sceneDisconnecting(std::shared_ptr<Scene> scene);
61 
66  virtual void sceneDisconnected(std::shared_ptr<Scene> scene);
67 
73  virtual void sceneDisconnected(std::shared_ptr<Scene>, std::string reason);
74 
82  virtual pplx::task<void> onGetSceneInfo(std::shared_ptr<IClient> client, const SceneAddress& address, const Federation& federation);
83 
84  virtual pplx::task<void> onConfigurationSet(std::shared_ptr<IClient> client, std::shared_ptr<Configuration> config);
85 
86 #pragma endregion
87 
88 #pragma region public_fields
89  std::weak_ptr<Configuration> configuration;
90 #pragma endregion
91  };
92 }
Definition: Federation.h:16
Definition: IPlugin.h:23
virtual void sceneDisconnected(std::shared_ptr< Scene > scene)
Called when the client has disconnected from a scene (deprecated)
virtual pplx::task< void > onGetSceneInfo(std::shared_ptr< IClient > client, const SceneAddress &address, const Federation &federation)
This method is executed before a call to getSceneEndpoint().
The ContainerBuilder is the primary element of the dependency injection mechanism....
Definition: DependencyInjection.h:401
Definition: IPlugin.h:39
Expose a stream for reading data received from the network.
Definition: IPlugin.h:21
Definition: Scene.h:23