示例#1
0
        public SimpleClient(string ip, int port, string username = "") : base()
        {
            try
            {
                this.AddCommand(MessageProtocols.LoginSuccess, LoginSuccessCommand);
                this.AddCommand(MessageProtocols.Fail, FailCommand);
                this.AddCommand(MessageProtocols.Connect, ConnectCommand);
                this.AddCommand(MessageProtocols.Disconnect, DisconnectCommand);
                this.AddCommand(MessageProtocols.Message, MessageCommand);
                this.AddCommand(MessageProtocols.Users, UsersCommand);
                this.AddCommand(MessageProtocols.Ping, PingCommand);
                this.AddCommand(MessageProtocols.Pong, PongCommand);

                //this.AddCommand(MessageProtocols.SetUsername, SetUsernameCommand);
                //this.AddCommand(MessageProtocols.UsernameTaken, UsernameTakenCommand);
                //this.AddCommand(MessageProtocols.UsernameChanged, UsernameChangedCommand);

                Socket connection = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                connection.Connect(new IPEndPoint(IPAddress.Parse(ip), port));
                this.Start(connection);
                SetupConnection();

                idle = new IdleChecker(this);
            }
            catch (Exception) {}
        }
示例#2
0
        public Browser(IConfig config)
        {
            InitCef();

            _browser = new ChromiumWebBrowser()
            {
                //Address = "http://92.53.101.102"
                Address = "http://neebower.github.io"
                          // Address = "http://google.com"
            };

            _browser.BrowserSettings.ApplicationCache = _enableApplicationCache ? CefState.Enabled : CefState.Disabled;


            _browser.RequestHandler = new CustomRequestHandler("HostWhitelist.xml");

            _configurator = new BrowserConfigurator(this, config);

            _defaultAddress = Address;

            if (!_openNewTabs)
            {
                _browser.LifeSpanHandler = new CustomLifeSpanHandler();
            }
            if (_hideContextMenu)
            {
                _browser.MenuHandler = new CustomContextMenuHandler();
            }
            Content = _browser;


            _idleChecker = new IdleChecker(180, 120, () => _browser.Load(_defaultAddress));
        }
示例#3
0
        static void RunServer()
        {
            var server = new ConnectionBuilder().CreateServer(25000);

            var manager     = new ServerManager();
            var idleChecker = new IdleChecker(1);

            server.OnInboundConnection += (c) =>
            {
                c.AddEventHandler(idleChecker);
                c.AddEventHandler(manager);
            };
            server.Start();
        }
示例#4
0
        public Worker(SimpleServer server, Socket connection, string username) : base()
        {
            this.AddCommand(MessageProtocols.Register, RegisterCommand);
            this.AddCommand(MessageProtocols.Login, LoginCommand);
            this.AddCommand(MessageProtocols.Message, MessageCommand);
            this.AddCommand(MessageProtocols.End, EndCommand);
            this.AddCommand(MessageProtocols.Ping, PingCommand);
            this.AddCommand(MessageProtocols.Pong, PongCommand);

            //this.AddCommand(MessageProtocols.SetUsername, SetUsernameCommand);

            this.server   = server;
            this.Username = username;
            this.Start(connection);
            idle = new IdleChecker(this);
        }