コード例 #1
0
        public void TestTcpClientConnectionListener3( )
        {
            const string connect = "127.0.0.1";
            const int port = 3003;

            Connections connections = new Connections( );

            TcpConnectionListener listener = new TcpConnectionListener( connect, port );
            listener.Listen( connections );

            TcpSocketConnection connection = new TcpSocketConnection( connect, port );
            connection.OpenConnection( );

            while ( connections.ConnectionCount == 0 ) {}

            TestMessage payload0 = new TestMessage( 10 );
            //TestMessage payload1 = new TestMessage( 11 );
            TestMessage payload1 = payload0;
            Message msg = new DualRefMessage( payload0, payload1 );
            connection.DeliverMessage( msg );

            connections.GetConnection( 0 ).Disconnect( );
            connections.ReceiveMessages( );

            connection.Disconnect( );
        }
コード例 #2
0
        public void TestTcpClientConnectionListener2( )
        {
            const string connect = "127.0.0.1";
            const int port = 3002;

            Connections connections = new Connections( );

            TcpConnectionListener listener = new TcpConnectionListener( connect, port );
            listener.Listen( connections );

            TcpSocketConnection connection = new TcpSocketConnection( connect, port );
            connection.OpenConnection( );

            connection.DeliverMessage( new TestMessage( 10 ) );
            connection.DeliverMessage( new TestMessage( 10 ) );

            while ( connections.ConnectionCount == 0 ) { }

            foreach ( IConnection curConnection in connections )
            {
                curConnection.ReceivedMessage += MessageChecker;
                curConnection.ReceiveMessages( );
            }

            listener.Dispose( );

            connection.Disconnect( );
        }
コード例 #3
0
        public void TestTcpClientConnectionListener0( )
        {
            const string connect = "127.0.0.1";
            const int port = 3000;

            Connections connections = new Connections( );

            TcpConnectionListener listener = new TcpConnectionListener( connect, port );
            listener.Listen( connections );
        }
コード例 #4
0
        public void TestTcpClientConnectionListener1( )
        {
            const string connect = "127.0.0.1";
            const int port = 3001;

            Connections connections = new Connections( );

            TcpConnectionListener listener = new TcpConnectionListener( connect, port );
            listener.Listen( connections );

            TcpSocketConnection connection = new TcpSocketConnection( connect, port );
            connection.OpenConnection( );

            connection.Disconnect( );

            connections.DisconnectAll( );
        }
コード例 #5
0
        private void HostForm_Load( object sender, EventArgs e )
        {
            //	Load input bindings
            CommandInputTemplateMap map = ( CommandInputTemplateMap )ResourceManager.Instance.Load( m_Setup.InputFile );
            m_User.InitialiseAllCommandListBindings( );

            //	Test load a scene
            Scene scene = new Scene( );

            //	Add a scene host
            scene.AddService( new Host( m_Setup.HostType, m_Setup.HostGuid ) );
            if ( m_Setup.HostType != HostType.Local )
            {
                IConnections connections = new Connections( );
                scene.AddService( connections );
                scene.AddService( new UpdateTarget( connections ) );
                scene.AddService( new UpdateSource( connections ) );

                RemoteHostAddress server = m_Setup.ServerAddress;
                if ( m_Setup.HostType == HostType.Client )
                {
                    TcpSocketConnection connection = new TcpSocketConnection( server.Address, server.Port );
                    connection.OpenConnection( );
                    connections.Add( connection );
                }
                else
                {
                    TcpConnectionListener listener = new TcpConnectionListener( server.Address, server.Port );
                    listener.Listen( connections );
                    scene.AddService( listener );
                }
            }

            //	Create a viewer for the scene
            try
            {
                ComponentLoadParameters loadParams = new ComponentLoadParameters( scene.Objects, scene.Builder, scene );
                loadParams.Properties[ "User" ] = m_User;
                ResourceManager.Instance.Load( m_Setup.SceneFile, loadParams );

                //	Naughty, just reuse loadParams (null out target because we don't want to load -into- the scene)
                loadParams.Target = null;
                loadParams.Properties[ "Subject" ] = scene;
                Viewer viewer = ( Viewer )ResourceManager.Instance.Load( m_Setup.ViewerFile, loadParams );
                display1.AddViewer( viewer );
            }
            catch ( Exception ex )
            {
                ExceptionUtils.ToLog( AppLog.GetSource( Severity.Error ), ex );
            }

            scene.GetClock( "inputClock" ).Subscribe( UpdateUser );

            //	Test load a command list
            try
            {
                //	TODO: AP: May need to move
                map.AddContextInputsToUser( new InputContext( display1.Viewers[ 0 ], display1 ), m_User );
            }
            catch ( Exception ex )
            {
                ExceptionUtils.ToLog( AppLog.GetSource( Severity.Error ), ex );
            }
        }