Ejemplo n.º 1
0
        private void WS_OnMessage(object sender, MessageEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(e.Data))
            {
                return;
            }
            WebInput input = JsonConvert.DeserializeObject <WebInput>(e.Data);

            if (input != null)
            {
                inputQueue.Enqueue(input);
            }
        }
Ejemplo n.º 2
0
    public void Start()
    {
        // setup web socket connection only if indicated
        if (connectToWebSocketServer)
        {
            // initialize connection to websocket server
            GameObject socketioGO = GameObject.Find("SocketIO");
            if (socketioGO == null)
            {
                Debug.LogError("[Unity2ServerSocketIO] Could not find SocketIO GameObject.");
            }
            unity2serverSocket = socketioGO.GetComponent <SocketIOComponent>();
            if (unity2serverSocket == null)
            {
                Debug.LogError("[Unity2ServerSocketIO] Could not find SocketIOComponent component of SocketIO GameObject.");
            }
            else
            {
                // register socket status events
                unity2serverSocket.On("open", SocketOpen);
                unity2serverSocket.On("error", SocketError);
                unity2serverSocket.On("close", SocketClose);

                // register socket input events
                unity2serverSocket.On(WEBUserWindIntensityUpdate, SocketInc_WEBUserWindIntensityUpdate);

                // debug
                unity2serverSocket.On("boop", TestBoop);
                unity2serverSocket.On("message", TestMessage);
            }

            // initialize connection to web input
            webInput = GameObject.Find("WebInput").GetComponent <WebInput>();


            // DEBUG
            //StartCoroutine("BeepBoop");
            //StartCoroutine("SendTestMessage");
        }
    }
Ejemplo n.º 3
0
 public WebReturn(object Data, WebInput input)
     : base(HEADER_RETURN, new object[] { Data }, input.UID, input.CID)
 {
 }