Ejemplo n.º 1
0
        public NeuronSource(string address, int port, int commandServerPort, NeuronConnection.SocketType socketType, IntPtr socketReference, IntPtr commandSocketReference)
        {
            this.address                = address;
            this.port                   = port;
            this.socketType             = socketType;
            this.socketReference        = socketReference;
            this.commandSocketReference = commandSocketReference;
            this.referenceCounter       = 0;

            // QueryNumOfActors();
        }
Ejemplo n.º 2
0
 public NeuronSource(
     string address, int port,
     NeuronConnection.SocketType socketType, IntPtr socket
     )
 {
     Address          = address;
     Port             = port;
     SocketType       = socketType;
     Socket           = socket;
     ReferenceCounter = 0;
 }
    public bool Connect(string address, int port, int commandServerPort, NeuronConnection.SocketType socketType)
    {
        NeuronSource source = NeuronConnection.Connect(address, port, commandServerPort, socketType);

        if (source != null)
        {
            source.RegisterResumeActorCallback(OnResumeActor);
            source.RegisterSuspendActorCallback(OnSuspendActor);
            sources.Add(source);
        }
        return(true);
    }
Ejemplo n.º 4
0
        public void SetBoundActor(NeuronActor actor)
        {
            if (boundActor != null)
            {
                UnregisterCallbacks();
            }

            if (actor != null)
            {
                boundActor = actor;
                RegisterCallbacks();
                actorID = actor.actorID;

                NeuronSource source = actor.owner;
                address           = source.address;
                port              = source.port;
                commandServerPort = source.commandServerPort;
                socketType        = source.socketType;

                standalone = false;
            }
        }
		public void SetBoundActor( NeuronActor actor )
		{
			if( boundActor != null )
			{
				UnregisterCallbacks();
			}
			
			if( actor != null )
			{
				boundActor = actor;
				RegisterCallbacks();
				actorID = actor.actorID;
				
				NeuronSource source = actor.owner;
				address = source.address;
				port = source.port;
				commandServerPort = source.commandServerPort;
				socketType = source.socketType;
				
				standalone = false;
			}
		}
Ejemplo n.º 6
0
    public void AddConnection()
    {
        string address = IPField.text.ToString();
        int    port    = int.Parse(PortField.text);

        NeuronSource source = FindSource(address, port);

        if (source != null)
        {
            if (source.numOfActiveActors == 0)
            {
                Disconnect(source.address, source.port);
            }
            else
            {
                Debug.Log(string.Format("[NeuronDebugViewer] Connection to {0}:{1} already present.", address, port));
                return;
            }
        }

        NeuronConnection.SocketType socketType = UDPToggle.isOn ? NeuronConnection.SocketType.UDP : NeuronConnection.SocketType.TCP;
        Connect(address, port, -1, socketType);
    }
Ejemplo n.º 7
0
 public NeuronAnimatorInstance(Animator animator, string address, int port, int commandServerPort, NeuronConnection.SocketType socketType, int actorID)
     : base(address, port, commandServerPort, socketType, actorID)
 {
     boundAnimator = animator;
     UpdateOffset();
 }
Ejemplo n.º 8
0
 public NeuronAnimatorInstance(string address, int port, int commandServerPort, NeuronConnection.SocketType socketType, int actorID)
     : base(address, port, commandServerPort, socketType, actorID)
 {
 }
Ejemplo n.º 9
0
 public NeuronInstance(string address, int port, int commandServerPort, NeuronConnection.SocketType socketType, int actorID)
 {
     standalone = true;
 }
Ejemplo n.º 10
0
 public NeuronTransformsInstance(Transform root, string prefix, string address, int port, int commandServerPort, NeuronConnection.SocketType socketType, int actorID)
     : base(address, port, commandServerPort, socketType, actorID)
 {
     //Debug.Log("2");
     Bind(root, prefix);
 }
Ejemplo n.º 11
0
 public NeuronTransformsInstance(string address, int port, int commandServerPort, NeuronConnection.SocketType socketType, int actorID)
     : base(address, port, commandServerPort, socketType, actorID)
 {
     //Debug.Log("1");
 }
Ejemplo n.º 12
0
    static NeuronSource CreateConnection(string address, int port, int commandServerPort, NeuronConnection.SocketType socketType)
    {
        NeuronSource source                 = null;
        IntPtr       socketReference        = IntPtr.Zero;
        IntPtr       commandSocketReference = IntPtr.Zero;

        if (socketType == NeuronConnection.SocketType.TCP)
        {
            socketReference = NeuronDataReader.BRConnectTo(address, port);
            if (socketReference != IntPtr.Zero)
            {
                if (bDebugLog)
                {
                    Debug.Log(string.Format("[NeuronConnection] Connected to {0}:{1}.", address, port));
                }
            }
            else
            {
                if (bDebugLog)
                {
                    Debug.LogError(string.Format("[NeuronConnection] Connecting to {0}:{1} failed.", address, port));
                }
            }
        }
        else
        {
            socketReference = NeuronDataReader.BRStartUDPServiceAt(port);
            if (socketReference != IntPtr.Zero)
            {
                if (bDebugLog)
                {
                    Debug.Log(string.Format("[NeuronConnection] Start listening at {0}.", port));
                }
            }
            else
            {
                if (bDebugLog)
                {
                    Debug.LogError(string.Format("[NeuronConnection] Start listening at {0} failed.", port));
                }
            }
        }

        if (socketReference != IntPtr.Zero)
        {
            if (commandServerPort > 0)
            {
                // connect to command server
                commandSocketReference = NeuronDataReader.BRConnectTo(address, commandServerPort);
                if (commandSocketReference != IntPtr.Zero)
                {
                    if (bDebugLog)
                    {
                        Debug.Log(string.Format("[NeuronConnection] Connected to command server {0}:{1}.", address, commandServerPort));
                    }
                }
                else
                {
                    if (bDebugLog)
                    {
                        Debug.LogError(string.Format("[NeuronConnection] Connected to command server {0}:{1} failed.", address, commandServerPort));
                    }
                }
            }

            source = new NeuronSource(address, port, commandServerPort, socketType, socketReference, commandSocketReference);
        }

        return(source);
    }