Пример #1
0
        private void Client_OnPacketReceived(object sender, PacketReceivedEventArgs <TCPClient <StreamPacket>, StreamPacket> e)
        {
            logger.LogInfo("Packet 0x{0:X16} has been received from client {1} at {2}", e.Packet.ID, e.Client.EndPoint, e.Time);

            if (e.Packet.ID == ulong.MaxValue)
            {
                string message = e.Packet.ReadString();
                logger.LogSuccess("Received message: {0}", message);
            }
            else
            {
                logger.LogWarning("Unknown packet!");
            }
        }
Пример #2
0
        public void SendMessage(string message)
        {
            if (Server.Clients.Length == 0)
            {
                logger.LogWarning("No clients connected!");
            }
            else
            {
                var packet = Server.CreatePacket(ulong.MaxValue);
                packet.WriteString(message);

                Server.SendToAll(packet);
            }
        }
Пример #3
0
        public bool Enable()
        {
            if (IsEnabled)
            {
                logger.LogWarning("{0} has already enabled!", Component.GetType().Name);
                return(true);
            }
            else if (Component.Enable())
            {
                logger.LogSuccess("{0} has enabled successfully!", Component.GetType().Name);
                IsEnabled = true;

                return(true);
            }
            else
            {
                logger.LogError("{0} has been failed to enable!!", Component.GetType().Name);
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// Returns the correct type of <see cref="IPersistenceConfigurer"/> for the selected
        /// database-type.
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="tempDirectory"></param>
        /// <returns></returns>
        private static IPersistenceConfigurer DatabaseTypeWithConnectionStringToConfigurer(DataFactoryConfiguration configuration)
        {
            if (configuration.DatabaseType == DatabaseType.SQLiteTemp)
            {
                var pathToFile = $"{Path.Combine(configuration.TempDirectory ?? Path.GetTempPath(), Path.GetRandomFileName())}.sqlite";
                logger.LogWarning("Using temporary SQLite file: {0}", pathToFile);
                return(SQLiteConfiguration.Standard.UsingFile(pathToFile));
            }

            var connString = configuration.DatabaseConnectionString;

            if (String.IsNullOrEmpty(connString) || String.IsNullOrWhiteSpace(connString))
            {
                throw new ArgumentException("Configuration's database connection string not valid.");
            }

            switch (configuration.DatabaseType)
            {
            case DatabaseType.MsSQL2000:
                return(MsSqlConfiguration.MsSql2000.ConnectionString(connString));

            case DatabaseType.MsSQL2005:
                return(MsSqlConfiguration.MsSql2005.ConnectionString(connString));

            case DatabaseType.MsSQL2008:
                return(MsSqlConfiguration.MsSql2008.ConnectionString(connString));

            case DatabaseType.MsSQL2012:
                return(MsSqlConfiguration.MsSql2012.ConnectionString(connString));

            case DatabaseType.MySQL:
                return(MySQLConfiguration.Standard.ConnectionString(connString));

            case DatabaseType.Oracle9:
                return(OracleDataClientConfiguration.Oracle9.ConnectionString(connString));

            case DatabaseType.Oracle10:
                return(OracleDataClientConfiguration.Oracle10.ConnectionString(connString));

            case DatabaseType.PgSQL81:
                return(PostgreSQLConfiguration.PostgreSQL81.ConnectionString(connString));

            case DatabaseType.PgSQL82:
                return(PostgreSQLConfiguration.PostgreSQL82.ConnectionString(connString));

            case DatabaseType.SQLite:
                return(SQLiteConfiguration.Standard.ConnectionString(connString));

            default:
                throw new NotSupportedException(
                          String.Format("Database-type {0} is not currently supported.", configuration.DatabaseType.ToString()));
            }
        }
Пример #5
0
 protected override void OnDisconnected(DisconnectReason reason)
 {
     logger.LogWarning("Client {0} disconnected by reason: {1}", Socket.EndPoint, reason);
 }
Пример #6
0
 protected override void OnServerClosed()
 {
     logger.LogWarning("ChatServer closed");
 }