Esempio n. 1
0
        private void StartClient()
        {
            _client = new ClientCommunicationService();
            if (_enableLogging)
            {
                ILoggerService loggerService = new LoggerService();
                _client.CurrentLogLevel = _logLevel;
                _client.LogFileName = _logFileName;
                _client.LoggerService = loggerService;
            }

            _client.MulticastIPAddress = _multicastIPAddress;
            _client.MulticastPort = _multicastPort;
            _client.ServerIPAddress = _serverIPAddress;
            _client.ServerPort = _serverPort;
            _client.UseMulticast = _useMulticast;
            _client.DataReceived += new EventHandler<DataReceivedEventArgs>(OnDataReceived);
            try
            {
                _client.Start();
                ClearGrid();
                SendRequestForMessageList();
            }
            catch (SocketException)
            {
                StopClient();
                MessageBox.Show(this, "Error connecting to server " + _serverIPAddress + ":" +
                                    _serverPort + Environment.NewLine + "Configure server address and port.", "Mocs Notification", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ShowConfigurationForm();
            }
        }
Esempio n. 2
0
        private void StartServerCommunication()
        {
            _server = new ServerCommunicationService();

            if (_useLogging)
            {
                ILoggerService loggerService = new LoggerService();
                _server.CurrentLogLevel = LogLevel.Info;
                _server.LogFileName = @"c:\server.txt";
                _server.LoggerService = loggerService;
            }

            _server.MulticastIPAddress = ConfigurationManager.AppSettings["MulticastIPAddress"];
            _server.MulticastPort = Int32.Parse(ConfigurationManager.AppSettings["MulticastPort"]);
            _server.ServerPort = Int32.Parse(ConfigurationManager.AppSettings["ServerPort"]);
            _server.DataReceived += new EventHandler<DataReceivedEventArgs>(_server_DataReceived);
            _server.Start();
        }