Пример #1
0
        private void testConnectionWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            Server.ServerVariables serverToConnectTest = (Server.ServerVariables)e.Argument;
            BombsHost.CommunicatorClient testConnector = new BombsHost.CommunicatorClient(new InstanceContext(this), binding, new EndpointAddress(string.Format(@"net.tcp://{0}:{1}/BombsHost/tcp", serverToConnectTest.Address, serverToConnectTest.Port.ToString())));

            testConnector.Endpoint.Name = "BOMBS_Service_Communicator_EndPoint";

            bool result = true;

            try
            {
                testConnector.Open();

                result = true;
            }
            catch
            {
                result = false;
            }

            object[] results = new object[3];

            results[0] = result;
            results[1] = testConnector;
            results[2] = serverToConnectTest;

            e.Result = results;
        }
Пример #2
0
        public void Connect()
        {
            connector = new BombsHost.CommunicatorClient(new InstanceContext(this), binding, new EndpointAddress(string.Format(@"net.tcp://{0}:{1}/BombsHost/tcp", activeServer.Address, activeServer.Port.ToString())));

            connector.Endpoint.Name = "BOMBS_Service_Communicator_EndPoint";
            try
            {
                connector.Open();
                OnConnectionStatusChange(Server.ConnectionStatus.Success);

                if (HostInitializedAndOpened != null) HostInitializedAndOpened(this, EventArgs.Empty);
            }
            catch
            {
                OnConnectionStatusChange(Server.ConnectionStatus.ConnectionFailure);
                return;
            }

            connector.GetServerInformationCompleted -= connector_GetServerInformationCompleted;
            connector.GetServerInformationCompleted += connector_GetServerInformationCompleted;

            connector.GetServerInformationAsync();
        }