Reputation: 13296
im wondering about how to use WCF service instead of sockets .. to send commands .. someone told me its more powerful than creating a client-server application my application about
//this function runs in its own thread
private void Job(object o)
{
Socket client = (Socket)o;
NetworkStream stream = new NetworkStream(client);
StreamReader sr = new StreamReader(stream);
try
{
string cmd = null;
while ((cmd = sr.ReadLine()) != null)
{
Console.WriteLine(cmd);
string[] command = cmd.Split('<');
switch (command[0])
{
case "root":
fmc.root();
break;
case "explore":
fmc.Explore(command[1]);
break;
case "new_folder":
fmc.NewFolder(command[1]);
break;
case "hidden":
fmc.HiddenChecked(command[1]);
break;
case "delete":
fmc.Delete(command[1]);
break;
case "properties":
if (command[1] == "single")
{
fmc.SingleProperties(command[2]);
}
else if (command[1] == "multi")
{
fmc.MultiProperties(command[2]);
}
else
{
fmc.DriveProperties(command[2]);
}
break;
case "pastefromcopy":
fmc.PasteFromCopy(command[1], command[2]);
break;
//case "confirm":
// break;
default:
Console.WriteLine(cmd);
break;
}
}
}
catch { client.Close(); stream.Dispose(); sr.Dispose(); }
}
so do you have any tutorial that would be close to my application.. to execute commands .. or if you can write me a simple client-server WCF .. that solve it the same way . thanks in advance :)
Upvotes: 1
Views: 3245
Reputation: 688
there are really so many articles out on the web for making a chat service using wcf. It really depends on the level of what you want to make and how much you would like to learn. I recommend you to go through a few of these videos here first to get the feel for wcf.
Then look through these to find an example of what you would like to create.
Have fun creating your service.
Upvotes: 3
Reputation: 820
The following link would be a good starting point. It details how to write a client server chat application in WCF.
Upvotes: 0