コード例 #1
0
        public ConnectionMultiplexer GetConnection()
        {
            if (connection != null && connection.IsConnected)
            {
                return(connection);
            }

            var sw = Stopwatch.StartNew();

            connection = ConnectionMultiplexer.Connect(configuration, connectionMultiplexerLog);
            sw.Stop();
            try
            {
                OnConnectionOpen?.Invoke(new OpenConnectionEventArgs(configuration, sw.Elapsed));

                // attach events
                connection.ConfigurationChanged          += connection_ConfigurationChanged;
                connection.ConfigurationChangedBroadcast += connection_ConfigurationChangedBroadcast;
                connection.ConnectionFailed   += connection_ConnectionFailed;
                connection.ConnectionRestored += connection_ConnectionRestored;
                connection.ErrorMessage       += connection_ErrorMessage;
                connection.HashSlotMoved      += connection_HashSlotMoved;
                connection.InternalError      += connection_InternalError;
            }
            catch
            {
                connection = null;
                throw;
            }

            return(connection);
        }
コード例 #2
0
        private void _WebSocket_OnOpen(object sender, EventArgs e)
        {
            _logger.Log(Log.LogLevel.Debug, "WebSocket opened");
            _lastReceivedTime = DateTime.UtcNow;

            OnConnectionOpen?.Invoke();
        }
コード例 #3
0
        private void _WebSocket_OnOpen(object sender, EventArgs e)
        {
            Console.WriteLine("WebSocket Opened");

            _lastReceivedTime = DateTime.UtcNow;

            OnConnectionOpen?.Invoke();
        }
コード例 #4
0
ファイル: IonTcpConnectionManager.cs プロジェクト: habb0/IHI
        /// <summary>
        ///   Handles a newly created IonTcpConnection and performs some checks, before adding it to the Connection collection and starting the client session.
        /// </summary>
        /// <param name = "connection">The IonTcpConnection instance representing the new Connection to handle.</param>
        public void HandleNewConnection(IonTcpConnection connection)
        {
            // TODO: check max simultaneous connections
            // TODO: check max simultaneous connections per IP
            // TODO: check project specific actions

            // INFO: client ID = Connection ID, client ID = session ID
            // Add Connection to collection
            lock (_connections)
                _connections.Add(connection.GetID(), connection);

            if (OnConnectionOpen != null)
            {
                OnConnectionOpen.Invoke(connection, null);
            }

            connection.Start();

            //IonEnvironment.GetHabboHotel().GetClients().StartClient(Connection.ID);
        }