Beispiel #1
0
 /// <summary>
 /// Initializes an instance of the <see cref="RestEndPoint"/> class.
 /// </summary>
 /// <param name="serverConfiguration">The server configuration.</param>
 /// <param name="accessTokenService">The access token service.</param>
 public RestEndPoint(IOptions <ServerConfiguration> serverConfiguration, IAccessTokenService accessTokenService)
 {
     _accessTokenService  = accessTokenService;
     _serverConfiguration = serverConfiguration.Value;
     MessageTypeCache.LoadMessageTypeCache();
     _resourcesToTypesMap = new ConcurrentDictionary <string, Route>(
         new[]
     {
         Route.Create <AuthenticateRequest>("/users/authenticate"),
         Route.Create <RegisterRequest>("/users/register"),
         Route.Create <GetEnabledTrainingRoomsRequest>("/trainingrooms/enabled", "Logged in")
     });
     _httpListener = new HttpListener();
     _httpListener.Prefixes.Add($"http://{_serverConfiguration.Host}:{_serverConfiguration.RestPort}/");
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of <see cref="BaseNetworkConnector"/> class.
 /// </summary>
 /// <remarks>
 /// Also loads the <see cref="MessageTypeCache"/> on the first <see cref="BaseNetworkConnector"/> instance creation.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If the messageProcessor is null; an argument exception is thrown.</exception>
 /// <param name="messageSerializer">The message serializer.</param>
 /// <param name="messageProcessor">The message processor.</param>
 protected BaseNetworkConnector(IMessageSerializer messageSerializer, IMessageProcessor messageProcessor)
 {
     _messageConstructor = new MessageConstructor(messageSerializer);
     _messageProcessor   = messageProcessor ?? throw new ArgumentNullException(nameof(messageProcessor));
     MessageTypeCache.LoadMessageTypeCache();
 }