Ejemplo n.º 1
0
        // Use this for initialization
        public void Start()
        {
            this.WaitStore = new TrafficWaitStore();
            // Example uri: ws://localhost:5678
            string uri = Utilities.getWebSocketPath();

            // Uncomment below when testing
            //uri = "ws://141.252.236.43:5678";

            Manipulator = new TrafficLightManipulator();
            Manipulator.PrepareTrafficLights();

            Debug.Log("Set to use " + uri);
            SocketClient            = new WebSocket(uri);
            SocketClient.OnMessage += SocketClientOnOnMessage;
            try
            {
                SocketClient.Connect();
                // Init request (for controllers that need some kind of signal)
                SocketClient.Send(Encoding.UTF8.GetBytes("[]"));
                Debug.Log("Connected to " + uri);
            }
            catch (Exception ex)
            {
                if (ex is SocketException || ex is InvalidOperationException)
                {
                    Debug.Log("Failure connecting to " + uri);
                    SocketClient = null;
                }
                else
                {
                    throw;
                }
            }
        }
Ejemplo n.º 2
0
 public TrafficWaitStore()
 {
     LightsWithTraffic = new List <string>();
     Instance          = this;
 }