[GH-ISSUE #443] Qussion About (For each client c in SelectedClients) #229

Closed
opened 2026-02-27 15:49:28 +03:00 by kerem · 17 comments
Owner

Originally created by @darknet1990 on GitHub (Apr 11, 2016).
Original GitHub issue: https://github.com/quasar/Quasar/issues/443

Hello Everyone i just need an answer for my Qussion and to understant more
Here is my code !!

Foreach (Client c in SelectedClients)
{

//# Here can i put any command wich every client will make it ?? Like >>

System.IO.Directory.Delete("C:\Jony", true);

//# every client in the list will delete this folder ??

}

Originally created by @darknet1990 on GitHub (Apr 11, 2016). Original GitHub issue: https://github.com/quasar/Quasar/issues/443 Hello Everyone i just need an answer for my Qussion and to understant more Here is my code !! Foreach (Client c in SelectedClients) { //# Here can i put any command wich every client will make it ?? Like >> System.IO.Directory.Delete("C:\Jony", true); //# every client in the list will delete this folder ?? }
kerem 2026-02-27 15:49:28 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DragonzMaster commented on GitHub (Apr 11, 2016):

It should send the command to each client that is selected in the Listview in main form.

<!-- gh-comment-id:208338494 --> @DragonzMaster commented on GitHub (Apr 11, 2016): It should send the command to each client that is selected in the Listview in main form.
Author
Owner

@darknet1990 commented on GitHub (Apr 11, 2016):

Thank You @DragonzMaster I mean there is no need to write any class in (client and server ) this code will excute what i want ? @DragonzMaster

<!-- gh-comment-id:208366857 --> @darknet1990 commented on GitHub (Apr 11, 2016): Thank You @DragonzMaster I mean there is no need to write any class in (client and server ) this code will excute what i want ? @DragonzMaster
Author
Owner

@DragonzMaster commented on GitHub (Apr 11, 2016):

You should add server packet and client packet and edit the the handler ( Core\Commands ) and add the new packets to serializer in the following files Core\Networking\server.cs AND Core\Networking\client.cs , but remember that this command will be sent ONLY to selected clients (may be 1,2 or 20 ... etc...) NOT all of them (except you have selected all the clients).
You can add a new item to context-menu and double click on it to add the code like the examples below.

Here are examples:

private void disconnectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Client c in GetSelectedClients())
            {
                new Core.Packets.ServerPackets.DoClientDisconnect().Execute(c);
            }
        }

private void elevateClientPermissionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Client c in GetSelectedClients())
            {
                new Core.Packets.ServerPackets.DoAskElevate().Execute(c);
            }
        }

private void startupManagerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Client c in GetSelectedClients())
            {
                if (c.Value.FrmStm != null)
                {
                    c.Value.FrmStm.Focus();
                    return;
                }
                FrmStartupManager frmStm = new FrmStartupManager(c);
                frmStm.Show();
            }
        }
<!-- gh-comment-id:208371170 --> @DragonzMaster commented on GitHub (Apr 11, 2016): You should add server packet and client packet and edit the the handler ( **Core\Commands** ) and add the new packets to serializer in the following files **Core\Networking\server.cs** AND **Core\Networking\client.cs** , but remember that this command will be sent **ONLY** to selected clients (may be 1,2 or 20 ... etc...) **NOT** all of them (except you have selected all the clients). You can add a new item to context-menu and double click on it to add the code like the examples below. Here are examples: ``` c# private void disconnectToolStripMenuItem_Click(object sender, EventArgs e) { foreach (Client c in GetSelectedClients()) { new Core.Packets.ServerPackets.DoClientDisconnect().Execute(c); } } private void elevateClientPermissionsToolStripMenuItem_Click(object sender, EventArgs e) { foreach (Client c in GetSelectedClients()) { new Core.Packets.ServerPackets.DoAskElevate().Execute(c); } } private void startupManagerToolStripMenuItem_Click(object sender, EventArgs e) { foreach (Client c in GetSelectedClients()) { if (c.Value.FrmStm != null) { c.Value.FrmStm.Focus(); return; } FrmStartupManager frmStm = new FrmStartupManager(c); frmStm.Show(); } } ```
Author
Owner

@darknet1990 commented on GitHub (Apr 11, 2016):

i mean if i write a Long code Between (foreach) without adding any packets to core like >>
_calculate every photo in this folder i think it must work _
I see soo much codes and function and clasess why we dont write what we want without this serializer and Core\Networking\server.cs *Core\Networking\client.cs * just we write what we want in the form directly between foreach or the selected client ?

i feel its a littile comlicated

<!-- gh-comment-id:208381345 --> @darknet1990 commented on GitHub (Apr 11, 2016): i mean if i write a Long code Between (**foreach**) without adding any packets to core like >> _calculate every photo in this folder i think it must work _ I see soo much codes and function and clasess why we dont write what we want without this **serializer** and **Core\Networking\server.cs** *_Core\Networking\client.cs *_ just we write what we want in the form directly between foreach or the selected client ? i feel its a littile comlicated
Author
Owner

@DragonzMaster commented on GitHub (Apr 11, 2016):

Sorry, this code won't work. you should do what I've mentioned before (adding new packets ,edit handler and add packets to serializer).

<!-- gh-comment-id:208399831 --> @DragonzMaster commented on GitHub (Apr 11, 2016): Sorry, this code won't work. you should do what I've mentioned before (adding new packets ,edit handler and add packets to serializer).
Author
Owner

@DragonzMaster commented on GitHub (Apr 11, 2016):

I Think This project uses this style to manage and add packets and make it serliazable. (hope I'm not wrong)
In my opinion it is not complicated but it is about code management.

<!-- gh-comment-id:208402025 --> @DragonzMaster commented on GitHub (Apr 11, 2016): I Think This project uses this style to manage and add packets and make it serliazable. (hope I'm not wrong) In my opinion it is not complicated but it is about code management.
Author
Owner

@LostSoulfly commented on GitHub (Apr 11, 2016):

Looks like you just want to delete a specific folder on each of the connect clients?

You wouldn't need to add your own packet, just use .DoPathDelete

if (_connectClient != null) new Core.Packets.ServerPackets.DoPathDelete(path, type).Execute(_connectClient);

and you could loop through _connectClient instead of the list itself, assuming you want to send it to every computer. Otherwise, look at the existing code to send the command only to the selected computers.

<!-- gh-comment-id:208470857 --> @LostSoulfly commented on GitHub (Apr 11, 2016): Looks like you just want to delete a specific folder on each of the connect clients? You wouldn't need to add your own packet, just use .DoPathDelete `if (_connectClient != null) new Core.Packets.ServerPackets.DoPathDelete(path, type).Execute(_connectClient);` and you could loop through _connectClient instead of the list itself, assuming you want to send it to _every_ computer. Otherwise, look at the existing code to send the command only to the selected computers.
Author
Owner

@darknet1990 commented on GitHub (Apr 11, 2016):

Yes Thanks for all answers i understand at the end that i can write my code (foreach) and put my command like my code between it ..
@LostSoulFly it was just an example i want to execute a long script in all connected clients but my command line is very long and complicated this why i asked this Qussion to avoid making any classes and serializer / packets ... if i am wrong please explain more ...

<!-- gh-comment-id:208488168 --> @darknet1990 commented on GitHub (Apr 11, 2016): Yes Thanks for all answers i understand at the end that i can write my code (**foreach**) and put my command like **my code** between it .. @LostSoulFly it was just an example i want to execute a long script in all **connected clients** but my command line is very long and complicated this why i asked this Qussion to avoid making any classes and serializer / packets ... if i am wrong please explain more ...
Author
Owner

@DragonzMaster commented on GitHub (Apr 11, 2016):

Unfortunately as I've mentioned before you have to add new packets/edit handler/add packets to serializer to make the code run on your clients, I think you can't just add your code between for-each block and it will work as the server ONLY send packets NOT code blocks .

<!-- gh-comment-id:208491006 --> @DragonzMaster commented on GitHub (Apr 11, 2016): Unfortunately as I've mentioned before you have to add **new packets/edit handler/add packets to serializer** to make the code run on your clients, I think you can't just add your code between **for-each** block and it will work as **the server ONLY send packets NOT code blocks** .
Author
Owner

@darknet1990 commented on GitHub (Apr 11, 2016):

yes you are true i actually tried just now and it dont work !!
it is just working on my one computer but others on my network no

<!-- gh-comment-id:208498194 --> @darknet1990 commented on GitHub (Apr 11, 2016): yes you are true i actually tried just now and it **dont work** !! it is just working on my one computer but others on my network **no**
Author
Owner

@LostSoulfly commented on GitHub (Apr 11, 2016):

@DragonzMaster is correct, I was misunderstanding your goal. If you are only putting your code between a "for each", it's only going to run on the server itself and not the clients.

<!-- gh-comment-id:208501154 --> @LostSoulfly commented on GitHub (Apr 11, 2016): @DragonzMaster is correct, I was misunderstanding your goal. If you are only putting your code between a "for each", it's only going to run on the server itself and not the clients.
Author
Owner

@DragonzMaster commented on GitHub (Apr 11, 2016):

I will try to simplify how it works and I hope that there is nothing wrong.
The server only send and recieve packets and these packets hold the data between the server and client, some of them are server packets like GetConnections and the others are client packets like GetConnectionsResponse and MUST be added to both of server and client.
These packets are serialized using NetSerializer to make it easy to travel over network and of course they are compressed.
Then there are the handlers as their mission is to deal with the data received from/sent to => server/client and do most of the magic using these data like adding them to listview or delete file .... etc.
Now I hope you understand how it is working so simply you CAN'T just add the code between foreach block as the code will only executed on your machine and doesn't even travel over network.

<!-- gh-comment-id:208541356 --> @DragonzMaster commented on GitHub (Apr 11, 2016): I will try to simplify how it works and I hope that there is nothing wrong. The server only send and recieve packets and these packets **hold the data** between the server and client, some of them are server packets like **GetConnections** and the others are client packets like **GetConnectionsResponse** and **MUST** be added to both of server and client. These packets are serialized using NetSerializer to make it easy to travel over network and of course they are compressed. Then there are the handlers as their mission is to deal with the data received from/sent to => server/client and do most of the magic using these data like adding them to listview or delete file .... etc. Now I hope you understand how it is working so simply you **CAN'T** just add the code between **foreach** block as the code will only executed on your machine and doesn't even travel over network.
Author
Owner

@darknet1990 commented on GitHub (Apr 12, 2016):

Yes @DragonzMaster thank you for your Explain i thout it will be easy but it seems i need some time to understant how it works spichaly this all of classes and packets i am c# porgramer but its my first time working at Sockets Project >>>

<!-- gh-comment-id:208716136 --> @darknet1990 commented on GitHub (Apr 12, 2016): Yes @DragonzMaster thank you for your Explain i thout it will be easy but it seems i need some time to understant how it works spichaly this all of classes and packets i am c# porgramer but its my first time working at Sockets Project >>>
Author
Owner

@DragonzMaster commented on GitHub (Apr 12, 2016):

No problem, I've faced the same thing the first time I tried to add a new feature but It's very easy and not that complicated. 😄 and you can guide with any existed feature and you will know how it works.
May be I can help you with the feature you want to add.
Sorry for my English.

<!-- gh-comment-id:208821062 --> @DragonzMaster commented on GitHub (Apr 12, 2016): No problem, I've faced the same thing the first time I tried to add a new feature but It's very easy and not that complicated. :smile: and you can guide with any existed feature and you will know how it works. May be I can help you with the feature you want to add. Sorry for my English.
Author
Owner

@darknet1990 commented on GitHub (Apr 12, 2016):

@DragonzMaster how can i contact you via what ? wich feature do you added ?

<!-- gh-comment-id:208892297 --> @darknet1990 commented on GitHub (Apr 12, 2016): @DragonzMaster how can i contact you via what ? wich feature do you added ?
Author
Owner

@DragonzMaster commented on GitHub (Apr 12, 2016):

You can fork the project and see if I can help you. I've added TCP Connections feature.

<!-- gh-comment-id:208903328 --> @DragonzMaster commented on GitHub (Apr 12, 2016): You can fork the project and see if I can help you. I've added TCP Connections feature.
Author
Owner

@darknet1990 commented on GitHub (Apr 12, 2016):

online i cannot put *my project *

<!-- gh-comment-id:208947233 --> @darknet1990 commented on GitHub (Apr 12, 2016): online i cannot put *_my project *_
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Quasar#229
No description provided.