Ejemplo n.º 1
0
    public void Connect()
    {
        if (!connecting && socket == null)
        {
            try {
                socket = GetComponent <SocketIOComponent> ();

                socket.url = url;
                socket.Standby();

                socket.On("open", SocketOpen);
                socket.On("ID", ReceiveID);
                socket.On("UpdateRoom", UpdateRoom);
                socket.On("GetRooms", GetRooms);
                socket.On("PingName", PingName);
                socket.On("PongName", PongName);
                socket.On("Quick", Quick);
                socket.On("Leady", Leady);
                socket.On("GameStart", GameStart);
                socket.On("Message", Message);
                socket.On("Transform", Trans);
                socket.On("Hit", Hit);
                socket.On("PlayerEliminate", PlayerEliminate);
                socket.On("PushSwitch", PushSwitch);
                socket.On("FirstObs", FirstObs);
                socket.On("Obs", Obs);
                socket.On("DestroyObs", DestroyObs);
                socket.On("StateUpdate", StateUpdate);
                socket.On("Dead", Dead);
                socket.On("HeartBeat", HeartBeat);
                socket.On("error", ReceiveError);
                socket.On("close", SocketClose);

                socket.Connect();
            } catch (Exception e) {
                connecting = false;
            }
        }
        else if (!connecting)
        {
            socket.Connect();
        }
    }