How to join a Windows Remote Desktop Connection session?

1,734

It's quite easy. Get your user to log into an RDP session. Then log into the same server using your credentials. Go to Remote Desktop Services Manager. Then right click on the Active user whose session you want to join and click Remote Control. They will receive a permission message and that's it - you're in the same session.

Share:
1,734

Related videos on Youtube

Bill
Author by

Bill

Updated on September 18, 2022

Comments

  • Bill
    Bill over 1 year

    Occasionally a newItem is received from a WebSocket and gets saved to useState with saveNewItem

    this then kicks off the useEffect block as expected.

    Update. If there is an object in the closeArray with the same openTime as the newItem I want to replace that object in closeArray with the newItem because it will have a new close

    Add. If there isn't an object in the closeArray with the same open time as newItem I want to push the new item into the array.

    Remove. And finally, if the array gets longer than 39 objects I want to remove of the first item.

    If I add closeArray to the array of useEffect dependencies I'm going to create a nasty loop, if I don't add it closeArray isn't going to get updated.

    I want usEffect to only fire off when newItem changes and not if closeArray changes, but I still want to get and set data to closeArray in useEffect

    interface CloseInterface {
      openTime: number;
      closeTime: number;
      close: number;
    }
    function App() {
      const [newItem, saveNewItem] = useState<CloseInterface>();
      const [closeArray, saveCloseArray] = useState<CloseInterface[]>([]);
    
      useEffect(() => {
        if (newItem) {
          let found = false;
          let arr = [];
          for (let i = 0; i < closeArray.length; i++) {
            if (closeArray[i].openTime === newItem.openTime) {
              found = true;
              arr.push(newItem);
            } else {
              arr.push(closeArray[i]);
            }
          }
          if (found === false) {
            arr.push(newItem)
          }
          if (arr.length === 39) arr.shift();
          saveCloseArray(arr);
        }
      }, [newItem]); // <--- I need to add closeArray but it will make a yucky loop
    

    If I do add closeArray to the useEffect dependancy array I get the error...

    index.js:1 Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.
        in App (at src/index.tsx:9)
        in StrictMode (at src/index.tsx:8)
    

    if I don't add closeArray to the useEffect dependancy array I get this error...

    React Hook useEffect has a missing dependency: 'closeArray'. Either include it or remove the dependency array  react-hooks/exhaustive-deps
    

    the second useEffect block gets the initial data for closeArray and listens to a WebSocket that updates newItem as it arrives.

      useEffect(() => {
        const getDetails = async () => {
          const params = new window.URLSearchParams({
            symbol: symbol.toUpperCase(),
            interval
          });
          const url = `https://api.binance.com/api/v3/klines?${params}&limit=39`;
          const response = await fetch(url, { method: "GET" });
          const data = await response.json();
          if (data) {
            const arrayLength = data.length;
            let newcloseArray = [];
            for (var i = 0; i < arrayLength; i++) {
              const openTime = data[i][0];
              const closeTime = data[i][6];
              const close = data[i][4];
              newcloseArray.push({ openTime, closeTime, close });
            }
            saveCloseArray(newcloseArray);
            const ws = new WebSocket("wss://stream.binance.com:9443/ws");
            ws.onopen = () =>
              ws.send(
                JSON.stringify({
                  method: "SUBSCRIBE",
                  params: [`${symbol}@kline_${interval}`],
                  id: 1
                })
              );
            ws.onmessage = e => {
              const data = JSON.parse(e.data);
              const value = data.k;
              if (value) {
                const openTime = value.t;
                const closeTime = value.T;
                const close = value.c;
                saveNewItem({ openTime, closeTime, close });
              }
            };
          }
        };
        getDetails();
      }, [symbol, interval]);
    
    • Ramhound
      Ramhound almost 11 years
      Its my understand that Desktop versions of Windows didn't even support multiple sessions.
    • GJ.
      GJ. almost 11 years
      @Ramhound I'm not referring to multiple sessions (which would allow independent usage and effectively violate the single-license of the desktop version), but to multiple users connected to the same session -- much in the way that VNC normally allows.
    • Bill
      Bill about 4 years
      yes react throws an error in the console asking me to add it to the dependency array
    • wxker
      wxker about 4 years
      In that case, please add the error to your question.
    • Bill
      Bill about 4 years
      added thanks for the improvement suggestion
    • wxker
      wxker about 4 years
      Ok, good that you've added the error when closeArray is in the dependency array. What about when it isn't? Is there an error then? If so please add it in as well.
    • Derek
      Derek about 4 years
      You're always calling saveCloseArray with a new array object, so that's why it always rerenders when you have closeArray as a dependency. You probably want to use the function updater syntax so you don't need the dependency, and basically just update the single entry in the array that needs to change. This operation is also better suited for a useCallback.
  • wxker
    wxker about 4 years
    This looks fine as it is. Is not having closeArray in useEffect's second argument causing any problems?
  • Bill
    Bill about 4 years
    Derek, thanks for this, I don't have a button, the new item is coming from a WebSocket that then saves the new item to saveNewItem can I just add newItem to the dependency array of updateEntry in your answer?
  • Derek
    Derek about 4 years
    no, you would simply use updateEntry in the handler of your websocket event. Please post as much of your relevant code as possible, makes it easier to help with the right solutions.
  • Bill
    Bill about 4 years
    I gave it a try and I get the error ` Line 56:6: React Hook useEffect has a missing dependency: 'closeArray'. Either include it or remove the dependency array. You can also do a functional update 'saveCloseArray(c => ...)' if you only need 'closeArray' in the 'saveCloseArray' call react-hooks/exhaustive-deps`
  • Shubham Khatri
    Shubham Khatri about 4 years
    @Bill My mistake, updated my answer, instead of closeArray you had to use prevCloseArray