Exemplo n.º 1
0
        /// <summary>
        /// ConnectToServer
        /// connects to the server for the given object
        /// </summary>
        /// <param name="newServer"></param>
        private void ConnectToServer(Server newServer)
        {
            DuplexChannelFactory <IDGServerController> channelFactory;

            NetTcpBinding tcpBinding = new NetTcpBinding();
            string        url        = newServer.Url;

            try
            {
                channelFactory = new DuplexChannelFactory <IDGServerController>(new InstanceContext(this), tcpBinding, url); // bind url to channel factory
                m_server       = channelFactory.CreateChannel();                                                             // create portal on remote server
                m_server.Subscribe(m_user);
            }
            catch (FaultException <GameServerFault> e)
            {
                MessageBox.Show("Error Connecting to Server, please  try again later\n\n" + e.Detail.Message);
                CloseWindow();
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("Error Connecting to Server, please  try again later\n");
                CloseWindow();
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Error Connecting to Server, please  try again later\n");
                CloseWindow();
            }
            catch (EndpointNotFoundException)
            {
                MessageBox.Show("Server Endpoint not avialable at this time, please  try again later\n");
                CloseWindow();
            }
        }
Exemplo n.º 2
0
    public void ConnectToServer(Server server)
    {
        DuplexChannelFactory <IDGServerController> channelFactory;

        NetTcpBinding tcpBinding = new NetTcpBinding();
        string        url        = server.Url;

        try
        {
            channelFactory = new DuplexChannelFactory <IDGServerController>(new InstanceContext(this), tcpBinding, url); // bind url to channel factory
            m_server       = channelFactory.CreateChannel();                                                             // create portal on remote server
            m_server.Subscribe(m_user);
        }
        catch (ArgumentNullException)
        {
        }
        catch (InvalidOperationException)
        {
        }
        catch (EndpointNotFoundException)
        {
        }
    }