Ejemplo n.º 1
0
        public override void Stop()
        {
            logger.Log("AppDigitalMedia clean up");
            if (worker != null)
            {
                worker.Abort();
            }

            if (datastream != null)
            {
                datastream.Close();
            }

            if (serviceHost != null)
            {
                serviceHost.Close();
            }

            if (appServer != null)
            {
                appServer.Dispose();
            }

            if (SignalR != null)
            {
                SignalR.Dispose();
            }
        }
 protected override System.Threading.Tasks.Task OnReceivedAsync(
     SignalR.IRequest request,
     string connectionId,
     string data)
 {
     return base.Connection.Broadcast(data);
 }
Ejemplo n.º 3
0
        public SignalR.Hubs.IHub Create(SignalR.Hubs.HubDescriptor descriptor)
        {
            if (descriptor.Type == null)
                return null;

            return (SignalR.Hubs.IHub)_kernel.Get(descriptor.Type);
        }
Ejemplo n.º 4
0
        private async Task Conectar(Profile profile)
        {
            btnFacebook.Visibility = Android.Views.ViewStates.Gone;
            Usuario usuarioNovo = new Usuario();

            usuarioNovo.Nome      = profile.FirstName;
            usuarioNovo.Sobrenome = profile.LastName;
            usuarioNovo.IDProfile = profile.Id;
            //await ChatDataStore<Usuario>.Instance.AddAsync(usuario);
            var connection = await SignalR.GetHubConnection();

            Usuario usuario = await new UsuarioRepository().GetUsuarioAsync(usuarioNovo.IDProfile);

            if (usuario == null)
            {
                await new UsuarioRepository().SalvarUsuarioAsync(usuarioNovo);
                await connection.InvokeAsync("Conectar", usuarioNovo);
            }
            else
            {
                await new UsuarioRepository().SalvarUsuarioAsync(usuarioNovo);
                await connection.InvokeAsync("Conectar", usuarioNovo);
            }

            //GetHash();

            jaEntrou = true;
            var intent = new Intent(this, typeof(PrincipalActivity));

            intent.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
            StartActivity(intent);
            Finish();
        }
Ejemplo n.º 5
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Sala);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            hubConnection = await SignalR.GetHubConnection();

            hubConnection.On <Mensagem>("ReceberMensagem", (novaMensagem) =>
            {
                RunOnUiThread(() =>
                {
                    novaMensagem.Tipo = UserType.OTHER;
                    mensagens.Add(novaMensagem);
                    AtualizarMensagens();
                });
            });

            #region eventos
            ovIB_Enviar.SetOnClickListener(this);
            ovET_Mensagem.SetOnKeyListener(this);
            ovET_Mensagem.AddTextChangedListener(this);
            #endregion
        }
 protected override System.Threading.Tasks.Task OnConnectedAsync(SignalR.Hosting.IRequest request, string connectionId)
 {
     UserCount += 1;
     Debug.WriteLine("OnConnectedAsync " + UserCount);
     this.Connection.Broadcast(UserCount);
     return base.OnConnectedAsync(request, connectionId);
 }
        public void StopServices()
        {
            WriteLog("停止服务");
            //StopConnectEngine();
            if (LocationService.u3dositionSP != null)
            {
                LocationService.u3dositionSP.Stop();
                LocationService.u3dositionSP = null;
            }

            if (httpHost != null)
            {
                httpHost.CloseAsync();
                httpHost = null;
            }
            if (SignalR != null)
            {
                SignalR.Dispose();
                SignalR = null;
            }

            if (wcfApiHost != null)
            {
                wcfApiHost.Close();
                wcfApiHost = null;
            }

            StopReceiveAlarm();
        }
Ejemplo n.º 8
0
        public void MapHub(IEndpointRouteBuilder bldr)
        {
            string url = SignalR.MakeUrl(nameof(YetaWF_Messenger_SiteAnnouncementsHub));

            Logging.AddLog($"{nameof(YetaWF_Messenger_SiteAnnouncementsHub)} adding route {url}");
            bldr.MapHub <YetaWF_Messenger_SiteAnnouncementsHub>(url);
        }
Ejemplo n.º 9
0
        public void MapHub(IEndpointRouteBuilder bldr)
        {
            string url = SignalR.MakeUrl(nameof(YetaWF_Messenger_BrowserNotificationsHub));

            Logging.AddLog($"{nameof(YetaWF_Messenger_BrowserNotificationsHub)} adding route {url}");
            bldr.MapHub <YetaWF_Messenger_BrowserNotificationsHub>(url);
        }
Ejemplo n.º 10
0
 private void WinFormsServer_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (SignalR != null)
     {
         SignalR.Dispose();
     }
 }
Ejemplo n.º 11
0
 public Judger(Entity.User user, SignalR.Client client)
 {
     ID = user.ID;
     Nickname = Helpers.ColorName.GetNicknameHtml(user.Nickname, 4000);
     Gravatar = Helpers.Gravatar.GetAvatarURL(user.Gravatar, 50);
     Motto = HttpUtility.HtmlEncode(user.Motto);
     Ratio = client.Ratio;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Stops the server and closes the form. Restart functionality omitted
 /// for clarity.
 /// </summary>
 private void ButtonStop_Click(object sender, RoutedEventArgs e)
 {
     SignalR.Dispose();
     ButtonStop.IsEnabled  = false;
     ButtonStart.IsEnabled = true;
     WriteToConsole("---------------------------");
     WriteToConsole("Сервер остановлен.");
 }
Ejemplo n.º 13
0
        public async Task <ActionResult> SkinMessaging()
        {
            await SignalR.UseAsync();

            Manager.ScriptManager.AddLast($"{AreaRegistration.CurrentPackage.AreaName}_{Module.ClassName}", $"new YetaWF_Messenger.SkinMessagingModule('{YetaWFManager.JserEncode(Module.ModuleHtmlId)}');");

            return(new EmptyResult());
        }
Ejemplo n.º 14
0
 protected override void OnClosing(CancelEventArgs e)
 {
     if (SignalR != null)
     {
         SignalR.Dispose();
     }
     base.OnClosing(e);
     Application.Current.Shutdown();
 }
Ejemplo n.º 15
0
        public async Task <ActionResult> SkinBrowserNotifications()
        {
            await SignalR.UseAsync();

            await Manager.AddOnManager.AddAddOnNamedAsync(AreaRegistration.CurrentPackage.AreaName, nameof(SkinBrowserNotificationsModule));

            Manager.ScriptManager.AddLast($"{AreaRegistration.CurrentPackage.AreaName}_{Module.ClassName}", $"new YetaWF_Messenger.SkinBrowserNotificationsModule('{Utility.JserEncode(Module.ModuleHtmlId)}');");

            return(new EmptyResult());
        }
        public string GenerateConnectionId(SignalR.IRequest request)
        {
            if (request.Cookies["connectionId"] != null)
            {
                return request.Cookies["connectionId"].Value;
            }

            else
                return Guid.NewGuid().ToString();
        }
Ejemplo n.º 17
0
        public static IAppBuilder UseSignalRService(this IAppBuilder app, string connectionString,
                                                    Action <HubServerBuilder> configure)
        {
            var signalr = SignalR.Parse(connectionString);
            var builder = new HubServerBuilder(SignalR.ServiceProvider, signalr);

            configure(builder);

            return(app);
        }
Ejemplo n.º 18
0
        public void Configuration(IAppBuilder app)
        {
            // Configure SignalR
            SignalR.Configure(app);

            // Configure Azure B2C
            // Lab

            // Configure WebApi
            Common.WebApi.Configure(app);
        }
Ejemplo n.º 19
0
        public async Task <ActionResult> Messaging()
        {
            await SignalR.UseAsync();

            Package currentPackage = AreaRegistration.CurrentPackage;
            await Manager.AddOnManager.AddAddOnNamedAsync(currentPackage.AreaName, "Messaging");

            EditModel model = new EditModel {
            };

            return(View(model));
        }
Ejemplo n.º 20
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddSignalRService();

            var signalr = SignalR.Parse(Configuration["SignalRService:ConnectionString"]);

            services.AddSingleton(typeof(SignalR), signalr);

            var timeService = new TimeService(signalr);

            services.AddSingleton(typeof(TimeService), timeService);
        }
Ejemplo n.º 21
0
        private async void Connectivity_ConnectivityChanged(object sender, Xamarin.Essentials.ConnectivityChangedEventArgs e)
        {
            if (e.NetworkAccess == Xamarin.Essentials.NetworkAccess.Internet)
            {
                await SignalR.GetHubConnection();

                await SalvarSalaWifi();

                salasFragment.Refresh();
                Android.Support.V4.App.FragmentTransaction ft = SupportFragmentManager.BeginTransaction();
                ft.Detach(salasFragment);
                ft.Attach(salasFragment);
                ft.Commit();
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 停止服务
        /// </summary>
        /// <returns></returns>
        private async Task StopServer()
        {
            if (SignalR != null)
            {
                //向客户端广播消息
                //hubContext = GlobalHost.ConnectionManager.GetHubContext<SignalRHub>();
                await HubContext.Clients.All.SendClose("服务端已关闭");

                //await hubContext.Clients.User("").SendClose("服务端已关闭");
                //释放对象
                SignalR.Dispose();
                SignalR = null;
                Log.Info("服务端已关闭...");
            }
        }
Ejemplo n.º 23
0
        public override void Close()
        {
            base.Close();

            ServerInfo.Exit();
            StopServer();

            // Thread.Sleep(2000);
#if NO
            if (SignalR != null)
            {
                SignalR.Dispose();
                SignalR = null;
            }
#endif
        }
Ejemplo n.º 24
0
        public bool Start()
        {
            var started = false;

            try
            {                
                int puerto = 6969;
                if (ConfigurationManager.AppSettings["SignalR_Port"] != null)
                {
                    int.TryParse(ConfigurationManager.AppSettings["SignalR_Port"], out puerto);

                    log.Information("SignalR. Configuración para el puerto de singalR (Puerto: {0})", puerto);
                }
                else
                {
                    log.Information("SignalR. No se ha encontrado la configuración del puerto, usando configuración por defecto (Puerto: {0})", puerto);
                }
                ServerURI = string.Format("http://+:{0}", puerto);

                // Si ya está levantado, lo eliminamos antes y lo volvemos a levantar
                if (SignalR != null)
                {
                    SignalR.Dispose();
                    SignalR = null;
                    GC.Collect();
                }                
                SignalR = WebApp.Start<Startup>(ServerURI);                                

                started = SignalR != null ? true : false;

                log.Trace("StartSignalRServer: SignalR Server started at " + ServerURI);

                PingPong();
            }
            catch (TargetInvocationException ex)
            {
                log.Error("RequestHub. Start() SignalR Server failed to start. A server is already running on [{0}]", ServerURI != null ? ServerURI : "null", ex);
            }
            catch (Exception ex)
            {
                log.Error("RequestHub. Start()", ex);
            }

            return started;
        }
Ejemplo n.º 25
0
        public Form1()
        {
            InitializeComponent();

            _hubConnection         = new HubConnectionBuilder().WithUrl("https://localhost:44394/hub").Build();
            _hubConnection.Closed += async(error) =>
            {
                await Task.Delay(new Random().Next(0, 5) * 1000);

                await _hubConnection.StartAsync();
            };
            _signalR = new SignalR(_hubConnection);
            _api     = new API();

            ghost.DisableTimer();

            invoker = new Invoker();
        }
Ejemplo n.º 26
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            // app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                var path = typeof(MessagingHub).Name;
                endpoints.MapGet("/", async context =>
                {
                    // suggested configuration for consumer & producer
                    var needsToBeSecure = !env.IsDevelopment();
                    var url             = context.Request.GetBaseUri();
                    url += $"/{typeof(MessagingHub).Name}";

                    var suggestedConfig = new SignalR
                    {
                        HubUrl          = url,
                        NeedsToBeSecure = needsToBeSecure
                    };

                    var serialized = JsonSerializer.Serialize(suggestedConfig);

                    await context.Response.WriteAsync($"{serialized}\n");

                    //var connection = MessagingHub.GetConnection(url, needsToBeSecure);
                    //await connection.StartAsync();
                    //var mySerializedObject = new
                    //{
                    //    ServerTime = DateTime.Now,
                    //    ServerSays = message
                    //};
                    //await connection.InvokeAsync(nameof(MessagingHub.Broadcast), mySerializedObject);
                });
                endpoints.MapHub <MessagingHub>(path);
            });
        }
Ejemplo n.º 27
0
    void Start()
    {
        uiText = GameObject.Find("Text").GetComponent <Text>();
        DisplayMessage(statusText);

        var signalR = new SignalR();

        signalR.Init(signalRHubURL);

        signalR.On(HANDLER_A, (string payload) =>
        {
            var json = JsonUtility.FromJson <JsonPayload>(payload);
            DisplayMessage($"{HANDLER_A}: {json.message}");
        });
        signalR.On(HANDLER_B, (string payload) =>
        {
            var json = JsonUtility.FromJson <JsonPayload>(payload);
            DisplayMessage($"{HANDLER_B}: {json.message}");
        });

        signalR.ConnectionStarted += (object sender, ConnectionEventArgs e) =>
        {
            Debug.Log($"Connected: {e.ConnectionId}");
            DisplayMessage(connectedText);

            var json1 = new JsonPayload
            {
                message = messageToSendA
            };
            signalR.Invoke(hubMethodA, JsonUtility.ToJson(json1));
            var json2 = new JsonPayload
            {
                message = messageToSendB
            };
            signalR.Invoke(hubMethodB, JsonUtility.ToJson(json2));
        };
        signalR.ConnectionClosed += (object sender, ConnectionEventArgs e) =>
        {
            Debug.Log($"Disconnected: {e.ConnectionId}");
            DisplayMessage(disconnectedText);
        };

        signalR.Connect();
    }
Ejemplo n.º 28
0
        public static async Task <bool> CreateGameLobby()
        {
            var gameSettings = ModelMapper.Mapper.Map <List <GameSettingDto> >(GameSettings.Values);
            var response     = await HttpHelper.Post <GameLobby, List <GameSettingDto> >("gamelobby", gameSettings);

            if (response.Response.IsSuccessStatusCode)
            {
                DataContainer.GameLobby = response.Result;
                await SignalR.Connect();

                //send request that creater is the lobby owner
                _ = SignalR.Connection.InvokeAsync("AssumeControlOfLobby", DataContainer.GameLobby.Code);

                return(true);
            }


            return(false);
        }
        public void StopServices()
        {
            try
            {
                Location.BLL.Tool.Log.NewLogEvent -= ListenToLog;

                WriteLog("停止服务");
                //StopConnectEngine();
                if (LocationService.u3dositionSP != null)
                {
                    LocationService.u3dositionSP.Stop();
                    LocationService.u3dositionSP = null;
                }
                if (locationServiceHost != null)
                {
                    locationServiceHost.Close();
                    locationServiceHost = null;
                }
                if (httpHost != null)
                {
                    httpHost.CloseAsync();
                    httpHost = null;
                }
                if (SignalR != null)
                {
                    SignalR.Dispose();
                    SignalR = null;
                }

                if (wcfApiHost != null)
                {
                    wcfApiHost.Close();
                    wcfApiHost = null;
                }

                StopReceiveAlarm();
            }
            catch (Exception ex)
            {
                ListenToLog(ex.ToString());
            }
        }
Ejemplo n.º 30
0
        public bool Stop()
        {
            var stopped = false;

            try
            {
                log.Debug("RequestHub. Stop() Se Procede a parar el servidor");

                if (SignalR != null)
                {
                    SignalR.Dispose();

                    stopped = true;                    
                }
            }
            catch (Exception ex)
            {
                log.Error("RequestHub. Stop()", ex);
            }
            return stopped;
        }
Ejemplo n.º 31
0
 public void Save(SignalR.Hub.Model.Domain.Config aConfig)
 {
     Settings.Default.AutoRegisterNickserv = aConfig.AutoRegisterNickserv;
     Settings.Default.ElasticSearchHost = aConfig.ElasticSearchHost;
     Settings.Default.ElasticSearchPort = aConfig.ElasticSearchPort;
     Settings.Default.SetFileHandlers(aConfig.FileHandlers);
     Settings.Default.IrcNick = aConfig.IrcNick;
     Settings.Default.IrcPasswort = aConfig.IrcPasswort;
     Settings.Default.IrcRegisterEmail = aConfig.IrcRegisterEmail;
     Settings.Default.JabberPassword = aConfig.JabberPassword;
     Settings.Default.JabberServer = aConfig.JabberServer;
     Settings.Default.JabberUser = aConfig.JabberUser;
     Settings.Default.MaxDownloadSpeedInKB = aConfig.MaxDownloadSpeedInKB;
     Settings.Default.Password = aConfig.Password;
     Settings.Default.ReadyPath = aConfig.ReadyPath;
     Settings.Default.TempPath = aConfig.TempPath;
     Settings.Default.UseElasticSearch = aConfig.UseElasticSearch;
     Settings.Default.UseJabberClient = aConfig.UseJabberClient;
     Settings.Default.UseWebserver = aConfig.UseWebserver;
     Settings.Default.WebserverPort = aConfig.WebserverPort;
     Settings.Default.Save();
 }
Ejemplo n.º 32
0
 public PinkPacman(SignalR signalr, string id)
 {
     _signalR = signalr;
     Id       = id;
 }
Ejemplo n.º 33
0
 public ActionResult Loginuser(SignalR.Chat.Models.Client chatter)
 {
     return View("ChatWindow", chatter);
 }
Ejemplo n.º 34
0
 public override Pacman CreatePacman(SignalR signalr, string id)
 {
     return(new RedPacman(signalr, id));
 }
Ejemplo n.º 35
0
 public SignalRAuthController(SignalR signalr)
 {
     _signalr = signalr;
 }
Ejemplo n.º 36
0
 protected override Task OnConnectedAsync(SignalR.Hosting.IRequest request, IEnumerable<string> groups, string connectionId)
 {
     Observable.Interval(TimeSpan.FromMilliseconds(ProcessIntervalMilSec))
         .Subscribe(x => ProcessLoop());
     return _emptyTask;
 }
Ejemplo n.º 37
0
 public void Initialize(SignalR.Client.IConnection connection)
 {
     // Not implemented by MemoryHost
 }
Ejemplo n.º 38
0
 public void Initialize(SignalR.Client.IConnection connection)
 {
 }
Ejemplo n.º 39
0
 protected override Task OnConnectedAsync(SignalR.Hosting.IRequest request, System.Collections.Generic.IEnumerable<string> groups, string connectionId)
 {
     return Connection.Broadcast("Client [" + connectionId + "] connected");
 }
Ejemplo n.º 40
0
 protected override Task OnConnectedAsync(SignalR.Hosting.IRequest request, IEnumerable<string> groups, string connectionId)
 {
     RunAsyncWorkers();
     return _emptyTask;
 }
Ejemplo n.º 41
0
 private void ActiveQuadSignalRNotifier_QuadSelectionConfirmed(SignalR.Container_EventsCallbacks.ActiveQuadContainer.QuadSelectionConfirmed args)
 {
     if (args.TheQuad.QuadId == this.userSelectedQuad.QuadId && args.Confirmed)
     {
         this.Notifications.text = "Quad selection confirmed.";
         this.Notifications.gameObject.SetActive(true);
         this.OkView.interactable = true;
     }
     else
     {
         this.Notifications.text = "Quad in use please select another.";
         this.Notifications.gameObject.SetActive(true);
         this.OkView.interactable = false;
     }
 }
Ejemplo n.º 42
0
 public void PublishObservation(SignalR.Common.Dto.Observation observation)
 {
     _observers.Where(observer => string.Equals(observer.ObserveeId, observation.Entity.Value, StringComparison.CurrentCultureIgnoreCase) && string.Equals(observer.ObservableId, observation.Observable.Value, StringComparison.CurrentCultureIgnoreCase))
               .ForEach(observer => observer.Process(observation.AsDynamicMessage()));
 }
Ejemplo n.º 43
0
 public void Initialize(SignalR.Client.IConnection connection)
 {
     foreach (IHttpClient server in _servers)
     {
         server.Initialize(connection);
     }
 }
Ejemplo n.º 44
0
 public SignalR()
 {
     instance = this;
 }
Ejemplo n.º 45
0
 public abstract Pacman CreatePacman(SignalR signalr, string id);