private void TryToConnect()
        {
            Socket toConnect  = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            var    settings   = new AppSettingsReader();
            string serverIp   = (string)settings.GetValue("ServerIp", typeof(string));
            string clientIp   = (string)settings.GetValue("ClientIp", typeof(string));
            string serverPort = (string)settings.GetValue("ServerPort", typeof(string));
            string clientPort = (string)settings.GetValue("ClientPort", typeof(string));

            IPEndPoint myAddress = new IPEndPoint(IPAddress.Parse(clientIp), int.Parse(clientPort));

            toConnect.Bind(myAddress);
            IPEndPoint serverAddress = new IPEndPoint(IPAddress.Parse(serverIp), int.Parse(serverPort));

            toConnect.Connect(serverAddress);
            connection      = new TCPConnection(toConnect);
            functionalities = new ClientServices(connection);
        }
예제 #2
0
        private void connectButton_Click(object sender, EventArgs e)
        {
            string port = portBox.Text;
            email = emailBox.Text;

            channel = new TcpChannel(Convert.ToInt32(port));
            ChannelServices.RegisterChannel(channel, true);

            ss = (ISchedulerServer)Activator.GetObject(typeof(ISchedulerServer),
                                    "tcp://localhost:8086/ISchedulerServer");

            ca = (CAInterface)Activator.GetObject(typeof(CAInterface),
                                    "tcp://localhost:6969/CA");

            cs = new ClientServices(this, ca, email);
            RemotingServices.Marshal(cs, "ClientServices", typeof(Participant));

            url = "tcp://localhost:" + port + "/ClientServices";

            service = GoogleCalendarUtils.buildCalendarService(email);

            connectButton.Enabled = false;
            portBox.Enabled = false;
            emailBox.Enabled = false;

            codeButton.Enabled = true;
            scheduleButton.Enabled = true;
        }