Example #1
0
        public void Start()
        {
            _config   = ServerConfig.LoadConfig();
            _receiver = new ServerReceiver(_server);
            _server   = ScsServerFactory.CreateServer(new ScsTcpEndPoint(_config.Ip, _config.Port));

            new ServerLogic(_receiver, _server);

            _server.ClientConnected += Client_Connected;

            _server.Start();


            Console.WriteLine("Enter something to close server");
            Console.ReadLine();
            _server.Stop();
        }
Example #2
0
        public ServerLogic(ServerReceiver receiver, IScsServer server)
        {
            _server = server;

            using (var reader = SqlHelper.ExecuteDataReader("SELECT * FROM Room"))
                while (reader.Read())
                {
                    var id          = Convert.ToInt32(reader["Id"].ToString());
                    var name        = reader["Name"].ToString();
                    var host        = reader["Host"].ToString();
                    var image       = reader["ImageUrl"].ToString();
                    var description = reader["Description"].ToString();
                    DataSingleton.Instance.Rooms[roomCount]            = new Room(id, name, host, image, description);
                    DataSingleton.Instance.Rooms[roomCount].InsideInfo = new Room.InsindeInfo(new List <UserClient>(),
                                                                                              new List <Dj>(), DataSingleton.Instance.Rooms[roomCount]);
                    roomCount++;
                }

            PeriodicTask.StartNew(1000, TrackRefresh);
        }