public static IConnectionContext Create(IWebSocketConnection webSocket,
                                                IConnectionLifetimeManager lifetimeManager,
                                                ISimpleProtocol simpleProtocol,
                                                IUserIdProvider userIdProvider)
        {
            var connectionId = webSocket.ConnectionInfo.Id.ToString();
            var context      = new ConnectionContext(connectionId, webSocket);

            context.Features.Set(simpleProtocol);
            context.Features.Set(lifetimeManager);
            context.UserIdentifier = userIdProvider.GetUserId(webSocket.ConnectionInfo);
            return(context);
        }
Beispiel #2
0
 public HaWebSocketServer(ServiceConfigurationOption option,
                          IConnectionLifetimeManager connectionLifetimeManager,
                          IServiceProvider serviceProvider,
                          IInvokeHandlerManager invokeHandlerManager,
                          IUserIdProvider userIdProvider,
                          ILoggerFactory loggerFactory)
 {
     this.serviceConfigurationOption = option;
     this.connectionLifetimeManager  = connectionLifetimeManager;
     this.innerWebSocketServer       = new WebSocketServer(serviceConfigurationOption.Location);
     this.loggerFactory        = loggerFactory;
     this.simpleProtocol       = serviceProvider.GetRequiredService <ISimpleProtocol>();
     this.invokeHandlerManager = invokeHandlerManager;
     this.logger         = loggerFactory.CreateLogger <HaWebSocketServer>();
     this.userIdProvider = userIdProvider;
 }
 public ObjectPushMessage(Message data, ISimpleProtocol protocol)
 {
     this._data     = data;
     this._protocol = protocol;
 }
Beispiel #4
0
 public static void SetProtocol(this IConnectionContext context, ISimpleProtocol simpleProtocol)
 {
     context.Features.Set(simpleProtocol);
 }