Esempio n. 1
0
        static void Main(string[] args)
        {
            // Construct model
            ServerDatabase d = new ServerDatabase();

            // Construct Server Controlller
            // ServerController c = new ServerController(d);

            // Start a websocket server at port 8550
            //ServerForm sf = new ServerForm(wss);
            var        wss = new WebSocketServer(8550);
            ServerForm sf  = new ServerForm(wss, d);

            //  ServerController c = new ServerController(sf.UpdateListEvents, sf.UpdateUserLists, sf, d);
            // Add the Echo websocket service
            //wss.AddWebSocketService<Echo>("/echo");

            // Add the Chat websocket service
            wss.AddWebSocketService <ServerController>("/chat", () => new ServerController(sf.UpdateListEvents, sf.UpdateUserLists, sf, sf.UpdateContacts, d));

            sf.Show();

            //Construct Form
            Application.Run();
        }
        /// <summary>
        /// This constructor constructs the ServerController
        /// </summary>
        /// <param name="ue"></param>
        /// <param name="uel"></param>
        /// <param name="sf"></param>
        /// <param name="o"></param>
        /// <param name="sd"></param>
        public ServerController(UpdateEvent ue, UserListUpdates uel, ServerForm sf, Observer o, ServerDatabase sd)
        {
            _registry.Add(o);
            _u        = ue;
            _ule      = uel;
            _database = sd;

            _sf     = sf;
            _logout = _sf.LogoutUser;

            _uc = _sf.UpdateChatrooms;
        }