public override void OnOpen()
        {
            try
            {
                var chaveSessaoWebSocketsRemetente = WebSocketContext.SecWebSocketKey;
                var usuarioConectado = _servicoUsuario.ConectarUsuario(_chaveAcesso, chaveSessaoWebSocketsRemetente);
                var conversas        = new List <Atendimento>();

                webSocketClient.Add(this);

                if (usuarioConectado.Atendente)
                {
                    EnviarParaAtendenteClientesAguardandoAtendimento();
                    EnviarParaAtendenteAtendimentosInicializados(usuarioConectado);
                }
                else
                {
                    EnviarParaAtendentesNovaConexao(usuarioConectado);
                }
            }
            catch (SessaoException ex)
            {
                webSocketClient.Remove(this);
                RetornarErro(ex);
            }
            catch (ValidacaoException ex)
            {
                RetornarErro(ex);
            }
            catch (Exception ex)
            {
                RetornarErro(ex);
            }
        }
Exemple #2
0
 protected override void OnClose()
 {
     if (!faulted)
     {
         clients.Remove(this);
         clients.Broadcast(string.Format("{0} left.", name));
     }
 }
Exemple #3
0
        private static void AddClient(WSHandler client)
        {
            string key = GetClientKey(client);

            if (!string.IsNullOrEmpty(key))
            {
                LogDebug($"New Websocket connection {key}");
                clientsWS.Remove(client);
                clientsWS.Add(client);
            }
        }
Exemple #4
0
 public override void OnClose()
 {
     if (Partner != null)
     {
         var request = new
         {
             Type = "PartnerClose",
         };
         Partner.Send(Json.Encode(request));
     }
     SocketCollection.Remove(this);
 }
Exemple #5
0
        public override void OnClose()

        {
            clients.Remove(this);

            clients.Broadcast(string.Format("{0} has gone away.", name));
        }
Exemple #6
0
 public override void OnClose()
 {
     // Free resources, close connections, etc.
     chatClients.Remove(this);
     //DBSupport.DeleteUser(this.user.Username);
     base.OnClose();
 }
        public override void OnClose()
        {
            try
            {
                DashBoardModel dbModel = new DashBoardModel();
                dbModel.UpdateLastModified(this.fileId, String.Format("{0:s}", DateTime.Now));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            if (clients.Any(a => a == this))
            {
                clients.Remove(this);
                TranslateMessage translateMessage = new TranslateMessage();
                translateMessage.ClientId = this.clientId;
                translateMessage.SendTime = DateTime.Now;
                translateMessage.UserId   = this.userId;
                translateMessage.UserName = this.userName;
                translateMessage.Color    = this.userColor.Name;
                translateMessage.IsClose  = true;
                foreach (var client in clients)
                {
                    if (((APVTranslator_Web.Socket.wsHandler)client).projectId == this.projectId && ((APVTranslator_Web.Socket.wsHandler)client).fileId == this.fileId)
                    {
                        string msgBack = JsonConvert.SerializeObject(translateMessage);
                        client.Send(msgBack);
                    }
                }
            }
            base.OnClose();
        }
 public override void OnClose()
 {
     clients.Remove(this);
     clients.Broadcast(string.Format("{0} has gone away " + name));
     aTimer.Stop();
     aTimer.Dispose();
 }
            public override void OnClose()
            {
                // Quan un usuari desconnecta, cal acomiadar-se'n, esborrar-ne el SocketHandler de la Collection i notificar a la resta que marxa

                this.Send(string.Format("A reveure,{0}!", _nom));
                Sockets.Remove(this);
                Sockets.Broadcast(string.Format("{0} ha marxat del grup", _nom));
            }
 public override void OnClose()
 {
     lock (_clients)
     {
         _clients.Remove(this);
     }
     base.OnClose();
 }
Exemple #11
0
        public override void OnClose()
        {
            this.userID = this.WebSocketContext.QueryString["userID"];
            WebSocketCollection wsClients = (WebSocketCollection)HttpContext.Current.Application["WSClients"];

            wsClients.Remove(this);
            HttpContext.Current.Application["WSClients"] = wsClients;
        }
 public override void OnClose()
 {
     Clients.Remove(this);
     if (ClientIds.ContainsKey(_playerToken.UserId))
     {
         ClientIds.Remove(_playerToken.UserId);
     }
 }
 public override void OnClose()
 {
     // Quan un usuari desconnecta, cal acomiadar-se'n, esborrar-ne el SocketHandler de la Collection i notificar a la resta que marxa
     this.Send("Adéu " + this._nom);
     Sockets.Broadcast(this._nom + " s'ha desconnectat, adéu!");
     Sockets.Remove(this);
     ObtenerListaUsuarios();
 }
 public override void OnClose()
 {
     // Quan un usuari desconnecta, cal acomiadar-se'n, esborrar-ne el SocketHandler de la Collection i notificar a la resta que marxa
     this.Send("Adeu " + this._nom);
     Sockets.Remove(this);
     usersOnline.Remove(_nom);
     Sockets.Broadcast("[" + DateTime.Now.ToString("HH:mm:ss") + "] " + this._nom + " left the chat.");
     Sockets.Broadcast("*" + string.Join(",", usersOnline));
 }
Exemple #15
0
 public override void OnClose()
 {
     logger.Debug("Disconnect [{0}] sessionId={1}", playerName, sessionId);
     AllClients.Remove(this);
     if (pAdapter != null)
     {
         pAdapter.Disconnect();
     }
 }
Exemple #16
0
 public override void OnClose()
 {
     //var strUsers = string.Empty;
     _procClients.Remove(this);
     //foreach (ProcessWebSocketFacturas handler in _procClients)
     //{
     //    strUsers += (strUsers == string.Empty ? "" : ",") + handler.Pid;
     //}
     //_procClients.Broadcast("user:" + strUsers);
 }
Exemple #17
0
        public override void OnClose()
        {
            Users.Remove(this);

            if (!string.IsNullOrWhiteSpace(CurrentChannel))
            {
                var sub = Connection.GetSubscriber();
                sub.Unsubscribe(CurrentChannel, OnChannelMessage);
            }
        }
Exemple #18
0
 public override void OnClose()
 {
     //var strPid = string.Empty;
     _procClients.Remove(this);
     //foreach (ProcessWebSocketPagos handler in _procClients)
     //{
     //    strPid += (strPid == string.Empty ? "" : ",") + handler.Pid;
     //}
     //_procClients.Broadcast("pid:" + strPid);
 }
Exemple #19
0
 /// <summary>
 /// Provides disconnection functionality
 /// remove connected user from websocket user collection
 /// </summary>
 public override void OnClose()
 {
     try
     {
         _chatUser.Remove(this);
         friends.Remove(this.connectedUser);
         disconnectSuccess = true;
     }
     catch (Exception)
     {
         disconnectSuccess = false;
     }
 }
        public override void OnClose()
        {
            _webSocketClients.Remove(this);

            var response = new ClientResponse()
            {
                Command = ResponseCommand.Disconnected,
            };

            var json = JsonConvert.SerializeObject(response);

            _webSocketClients.Broadcast(json);
        }
Exemple #21
0
        public static bool RemoveClient(string id)
        {
            if (clientsMap.ContainsKey(id))
            {
                clients.Remove(clientsMap[id]);
                clientsMap.Remove(id);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #22
0
        public override void OnClose()
        {
            Locker.EnterWriteLock();

            try
            {
                ChatClients.Remove(this);
                var message = new { type = "CONNECTION", text = $"{_username} left." };
                ChatClients.Broadcast(JsonConvert.SerializeObject(message));
            }
            finally
            {
                Locker.ExitWriteLock();
            }
        }
Exemple #23
0
        public void Disconnect(GameConnection connection)
        {
            clients.Remove(connection.Client);

            if (clients.Count == 0 && gameTimer != null)
            {
                gameTimer.Dispose();
            }

            if (Started)
            {
                ProcessCommand(new RemovePlayerCommand(connection.Player));
            }
            else
            {
                game.Players.Remove(connection.Player);
            }
        }
        public override void OnClose()
        {
            if (hashId != null)
            {
                var curGame = Games.FirstOrDefault(g => g.ParticipantsHashId.Contains(hashId));
                if (curGame != null)
                {
                    if (curGame.HostHashId == hashId)
                    {
                        Games.Remove(curGame);
                    }
                    else
                    {
                        var gameService       = new GameService(_token);
                        var disconnectMessage = new DisconnectMessage()
                        {
                            GameHashId = curGame.HashId
                        };
                        gameService.DisconnectOfGame(disconnectMessage);

                        dynamic leaveMessage = new JObject();
                        leaveMessage.user_id    = hashId;
                        leaveMessage.match_id   = curGame.HashId;
                        leaveMessage.event_type = 0;

                        foreach (var playerId in curGame.ParticipantsHashId)
                        {
                            clientUser[playerId].Send(leaveMessage.ToString());
                        }
                    }
                }
                if (hashId != null)
                {
                    clientUser.Remove(hashId);
                }
            }
            Clients.Remove(this);
        }
 public override void OnClose()
 {
     clients.Remove(this);
 }
 /// <summary>
 /// When a client connection closes.
 /// </summary>
 public override void OnClose()
 {
     // Remove client.
     _clients.Remove(this);
 }
Exemple #27
0
 public override void OnClose()
 {
     Sockets.Remove(this);
 }
 public override void OnError()
 {
     clients.Remove(this);
 }
Exemple #29
0
 public override void OnClose()
 {
     clients.Remove(this);
     OnMessage("ConnectedUserList#" + this.GetConnectedUserListJson(clients));
     clients.Broadcast(string.Format("{0}|çıkış yaptı.", this.connectedUser.UserName));
 }
Exemple #30
0
 public override void OnClose()
 {
     name = this.WebSocketContext.QueryString["name"];
     clients.Remove(this);
     clients.Broadcast(name + " is disconnted");
 }