Exemplo n.º 1
0
 private void upgradeConnectionTorfc6455()
 {
     service         = webSocketServices[request.path].buildService(this);
     ConnectionRead -= StatefulWebSocketHandShake;
     ConnectionRead += StatefulWebsocketHandler;
     Send(new WebsocketUpgrade(request.getAttribute("Sec-WebSocket-Key")).ToBytes());
 }
Exemplo n.º 2
0
        public MessagesController(IDccRepository rebo, IMapper mapper, IWebSocketService webSocketService)
        {
            _mapper = mapper;
            _rebo   = rebo;

            _webSocketService = webSocketService;
        }
Exemplo n.º 3
0
        private async Task Listening(WebSocket webSocket, IWebSocketService webSocketService)
        {
            var buffer = new byte[1024 * 1];

            var result = await webSocket.ReceiveAsync(buffer, CancellationToken.None);

            while (!result.CloseStatus.HasValue)
            {
                // 发送数据
                var data = webSocketService.GetSendData(null);
                if (data != null)
                {
                    await webSocket.SendAsync(new ArraySegment <byte>(buffer, 0, result.Count),
                                              WebSocketMessageType.Binary, true, CancellationToken.None);
                }

                // 处理数据
                buffer = new byte[1024 * 1];
                result = await webSocket.ReceiveAsync(buffer, CancellationToken.None);

                await webSocketService.HandleReceivedData(result);
            }

            await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
        }
Exemplo n.º 4
0
 public ChatService(
     IUnitOfWork unitOfWork,
     IChatRoomRepository chatRoomRepository,
     IWebSocketService webSocketService)
 {
     _unitOfWork         = unitOfWork;
     _chatRoomRepository = chatRoomRepository;
     _webSocketService   = webSocketService;
 }
Exemplo n.º 5
0
        public StreamlabsClient(Config config, IWebSocketService webSocketService)
        {
            _config                    = config;
            _webSocketService          = webSocketService;
            _webSocketService.OnOpen  += OnOpen;
            _webSocketService.OnClose += OnClose;
            _webSocketService.OnError += OnError;
            Connect();

            Plugin.Log.Notice("Streamlabs Client Constructed");
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IDataService dataService, IPlayer player, IWebSocketService webSocketService)
        {
            DataService      = dataService;
            Player           = player;
            WebSocketService = webSocketService;

            GetDesignData();
            RefreshSongs();

            OpenSettingsCommand       = new RelayCommand(() => IsSettingsVisible = true);
            PauseCommand              = new RelayCommand(Pause);
            PlayCommand               = new RelayCommand(Play);
            TogglePlayPauseCommand    = new RelayCommand(TogglePlayPause);
            PlayOnDemandCommand       = new RelayCommand(PlayOnDemand);
            SaveSettingsCommand       = new RelayCommand(SaveSettings);
            ToggleShuffleCommand      = new RelayCommand(ToggleShuffle);
            OpenAlbumCommand          = new RelayCommand(OpenSelectedAlbum);
            CloseSelectedAlbumCommand = new RelayCommand(CloseSelectedAlbum);

            // Playback Precentage Update
            StopPrecentageUpdateCommand  = new RelayCommand(() => IsPrecentageUpdateActive = false);
            StartPrecentageUpdateCommand = new RelayCommand(() => { SetPlayTime(); IsPrecentageUpdateActive = true; });

            // Music Folders Commands
            AddMusicFolderCommand    = new RelayCommand(AddMusicFolder);
            RemoveMusicFolderCommand = new RelayCommand(RemoveMusicFolder, () => !string.IsNullOrEmpty(MusicSearchPath));

            // Event Listeners
            StartSongPositionListener();

            // Start Web Socket
            LydRemoteInstructions = "Lyd Remote is Starting...";
            WebSocketService.Start();
            LydRemoteInstructions = "Visit \"" + DataService.GetLocalIPAddress() + ":8080\" in a web browser to use Lyd Remote";

            // Attach Event Handler For Web Service
            HtmlData.PlaySong += (obj, x) =>
            {
                Song song = Songs.Where(s => s.ID == x).FirstOrDefault();
                PlayOnDemand(song);
            };

            HtmlData.ShufflePlay += (obj, e) =>
            {
                Shuffle();
            };

            HtmlData.PlayPause += (obj, e) =>
            {
                TogglePlayPause();
            };
        }
Exemplo n.º 7
0
        public WebSocketFeature(IFullNodeBuilder fullNodeBuilder,
                                FullNode fullNode,
                                IWebSocketService service,
                                WebSocketSettings settings,
                                ILoggerFactory loggerFactory)
        {
            this.fullNodeBuilder = fullNodeBuilder;
            this.fullNode        = fullNode;
            this.service         = service;
            this.settings        = settings;
            this.loggerFactory   = loggerFactory;

            this.loggerFactory.AddProvider(new WebSocketLoggingProvider(service, new WebSocketLoggerConfiguration()));
        }
Exemplo n.º 8
0
 public AuthenticationService(
     IHttpService httpService,
     NavigationManager navigationManager,
     ILocalStorageService localStorageService,
     IWebSocketService webSocketService,
     AbstractOrderService orderService
     )
 {
     _httpService         = httpService;
     _navigationManager   = navigationManager;
     _localStorageService = localStorageService;
     _webSocketService    = webSocketService;
     _orderService        = orderService;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="webSocketService">Provide methods and events to communicate with websocket server</param>
 /// <param name="messageService"></param>
 public AccountService(IWebSocketService webSocketService, IMessageService messageService)
 {
     State            = LoginState.Disconnected;
     WebSocketService = webSocketService;
     MessageService   = messageService;
     if (WebSocketService.GetState() == WebSocketState.Open)
     {
         SetState(LoginState.Guest);
     }
     WebSocketService.OnStateChange += (wsState) =>
     {
         if (wsState == WebSocketState.Open)
         {
             SetState(LoginState.Guest);
         }
         else
         {
             SetState(LoginState.Disconnected);
         }
     };
 }
 public WebSocketDemoController(IWebSocketService webSocketService)
 {
     _webSocketService = webSocketService;
 }
Exemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IDataService dataService, IPlayer player, IWebSocketService webSocketService)
        {
            DataService = dataService;
            Player = player;
            WebSocketService = webSocketService;

            GetDesignData();
            RefreshSongs();

            OpenSettingsCommand = new RelayCommand(() => IsSettingsVisible = true);
            PauseCommand = new RelayCommand(Pause);
            PlayCommand = new RelayCommand(Play);
            TogglePlayPauseCommand = new RelayCommand(TogglePlayPause);
            PlayOnDemandCommand = new RelayCommand(PlayOnDemand);
            SaveSettingsCommand = new RelayCommand(SaveSettings);
            ToggleShuffleCommand = new RelayCommand(ToggleShuffle);
            OpenAlbumCommand = new RelayCommand(OpenSelectedAlbum);
            CloseSelectedAlbumCommand = new RelayCommand(CloseSelectedAlbum);

            // Playback Precentage Update
            StopPrecentageUpdateCommand = new RelayCommand(() => IsPrecentageUpdateActive = false);
            StartPrecentageUpdateCommand = new RelayCommand(() => { SetPlayTime(); IsPrecentageUpdateActive = true; });

            // Music Folders Commands
            AddMusicFolderCommand = new RelayCommand(AddMusicFolder);
            RemoveMusicFolderCommand = new RelayCommand(RemoveMusicFolder, () => !string.IsNullOrEmpty(MusicSearchPath));

            // Event Listeners
            StartSongPositionListener();

            // Start Web Socket
            LydRemoteInstructions = "Lyd Remote is Starting...";
            WebSocketService.Start();
            LydRemoteInstructions = "Visit \"" + DataService.GetLocalIPAddress() + ":8080\" in a web browser to use Lyd Remote";

            // Attach Event Handler For Web Service
            HtmlData.PlaySong += (obj, x) =>
            {
                Song song = Songs.Where(s => s.ID == x).FirstOrDefault();
                PlayOnDemand(song);
            };

            HtmlData.ShufflePlay += (obj, e) =>
            {
                Shuffle();
            };

            HtmlData.PlayPause += (obj, e) =>
            {
                TogglePlayPause();
            };
        }
Exemplo n.º 12
0
 public WebSocketLogger(string name, IWebSocketService service, WebSocketLoggerConfiguration config)
 {
     this.name    = name;
     this.config  = config;
     this.service = service;
 }
Exemplo n.º 13
0
 public WebSocketLoggingProvider(IWebSocketService service, WebSocketLoggerConfiguration config)
 {
     this.config  = config;
     this.service = service;
 }
Exemplo n.º 14
0
 public MessagesController(IWebSocketService service)
 {
     _service = service;
 }
Exemplo n.º 15
0
 public void addWebSocketService(string prefix, IWebSocketService service)
 {
     webSocketServices[prefix] = service;
 }
Exemplo n.º 16
0
 public FullNodeHub(IWebSocketService webSocketService, FullNode fullNode)
 {
     this.fullNode         = fullNode;
     this.webSocketService = webSocketService;
 }
 public WebserviceController(IWebSocketService websocketService) => _websocketService = websocketService;
Exemplo n.º 18
0
 public WebSocketManager(IWebSocketService webSocketService)
 {
     _webSocketService = webSocketService;
 }
 private void upgradeConnectionTorfc6455()
 {
     service = webSocketServices[request.path].buildService(this);
     ConnectionRead -= StatefulWebSocketHandShake;
     ConnectionRead += StatefulWebsocketHandler;
     Send(new WebsocketUpgrade(request.getAttribute("Sec-WebSocket-Key")).ToBytes());
 }
 public void addWebSocketService(string prefix, IWebSocketService service)
 {
     webSocketServices[prefix] = service;
 }
Exemplo n.º 21
0
 public static IApplicationBuilder MapWebSocketManager(this IApplicationBuilder app,
                                                       PathString path,
                                                       IWebSocketService handler)
 {
     return(app.Map(path, (_app) => _app.UseMiddleware <WebSocketMiddleware>(handler.GetWebsocketMannager())));
 }
Exemplo n.º 22
0
        public static IWebHostBuilder CreateWebHostBuilder(FullNode fullNode, IEnumerable <ServiceDescriptor> services, IWebSocketService webSocketService, string[] args)
        {
            return(WebHost.CreateDefaultBuilder(args)
                   .ConfigureServices(collection =>
            {
                // copies all the services defined for the full node to the Api.
                // also copies over singleton instances already defined
                foreach (ServiceDescriptor service in services)
                {
                    object obj = fullNode.Services.ServiceProvider.GetService(service.ServiceType);
                    if (obj != null && service.Lifetime == ServiceLifetime.Singleton && service.ImplementationInstance == null)
                    {
                        collection.AddSingleton(service.ServiceType, obj);
                    }
                    else
                    {
                        collection.Add(service);
                    }
                }

                collection.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(IWebSocketService), webSocketService));
            })
                   .UseStartup <Startup>().UseUrls("http://localhost:4336"));
        }