// Update is called once per frame
 void Update()
 {
     if (fusionSocket == null)
     {
         fusionSocket = (FusionSocket)GameObject.Find("CommunicationsBridge").GetComponent <CommunicationsBridge>().
                        FindSocketConnectionByLabel("Fusion");
         if (fusionSocket != null)
         {
             fusionSocket.FusionReceived += ReceivedGesture;
         }
     }
 }
예제 #2
0
    public void SocketTest()
    {
        FusionSocket socket = new FusionSocket();

        socket.Connect("localhost", 8887);
        int i = 0;

        while (i < 20)
        {
            Debug.Log(socket.GetMessage());
            Thread.Sleep(1000);
            Debug.Log(i++);
        }

        socket.Close();
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        if (_fusionSocket != null)
        {
            string fusionUrl = string.Format("{0}:{1}", _fusionSocket.Address, _fusionSocket.Port);
            if (_fusionSocket.IsConnected())
            {
                if (commBridge.tryAgainSockets.ContainsKey(fusionUrl))
                {
                    if (commBridge.tryAgainSockets[fusionUrl] == typeof(FusionSocket))
                    {
                        _fusionSocket = (FusionSocket)commBridge.FindSocketConnectionByLabel("Fusion");
                        //Debug.Log(_fusionSocket.IsConnected());
                    }
                }

                string inputFromFusion = _fusionSocket.GetMessage();
                if (inputFromFusion != "")
                {
                    Debug.Log(inputFromFusion);
                    Debug.Log(_fusionSocket.HowManyLeft() + " messages left.");
                    _fusionSocket.OnFusionReceived(this, new FusionEventArgs(inputFromFusion));
                }
            }
            else
            {
                //SocketConnection _retry = socketConnections.FirstOrDefault(s => s.GetType() == typeof(FusionSocket));
                //TryReconnectSocket(_fusionSocket.Address, _fusionSocket.Port, typeof(FusionSocket), ref _retry);
                //_fusionSocket.OnConnectionLost(this, null);
                if (!commBridge.tryAgainSockets.ContainsKey(fusionUrl))
                {
                    commBridge.tryAgainSockets.Add(fusionUrl, _fusionSocket.GetType());
                }
            }
        }
    }
예제 #4
0
 // Use this for initialization
 void Start()
 {
     commBridge    = GameObject.Find("CommunicationsBridge").GetComponent <CommunicationsBridge>();
     _fusionSocket = (FusionSocket)commBridge.FindSocketConnectionByLabel("Fusion");
 }