Exemplo n.º 1
0
        public NewConnection()
        {
            InitializeComponent();

            communicator = ServiceController.Communicator;

            serverVariables = new ServerVariables();
            DataContext = serverVariables;
            OnDialogContentRequest += NewConnection_OnDialogContentRequest;
        }
Exemplo n.º 2
0
        private void OnTestConnectionCompleted(bool result, BombsHost.CommunicatorClient testCommunicator, Server.ServerVariables serverVariables)
        {
            serverToConnect = serverVariables;
            if (TestConnectionCompleted != null)
            {
                if (!result)
                {
                    TestConnectionCompleted(this, new ResultArg()
                    {
                        Result = new Server.TestConnectionVariablesArgs()
                        {
                            IsTestConnectionSuccessful = false,
                            ServerInformation = null
                        }
                    });
                }
                else
                {
                    if (testCommunicator != null)
                    {
                        testResultHost = testCommunicator;

                        testResultHost.GetServerInformationCompleted -= testCommunicator_GetServerInformationCompleted;
                        testResultHost.GetServerInformationCompleted += testCommunicator_GetServerInformationCompleted;

                        testResultHost.GetServerInformationAsync();
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void connector_DisconnectCompleted(object sender, AsyncCompletedEventArgs e)
        {
            connector.DisconnectCompleted -= connector_DisconnectCompleted;
            connector.Close();
            activeServer = serverToConnect;
            connector = testResultHost;

            if (HostInitializedAndOpened != null) HostInitializedAndOpened(this, EventArgs.Empty);
            if (NewConnectionImplemented != null) NewConnectionImplemented(this, new ResultArg() { Result = connector });
        }
Exemplo n.º 4
0
 public void UseNewHost()
 {
     if (connector != null)
     {
         if (connector.State == CommunicationState.Opened)
         {
             connector.DisconnectCompleted += connector_DisconnectCompleted;
             connector.DisconnectAsync();
         }
         else
         {
             connector.Close();
             connector = testResultHost;
             activeServer = serverToConnect;
             if (HostInitializedAndOpened != null) HostInitializedAndOpened(this, EventArgs.Empty);
         }
     }
     else
     {
         connector = testResultHost;
         activeServer = serverToConnect;
         if (HostInitializedAndOpened != null) HostInitializedAndOpened(this, EventArgs.Empty);
     }
 }