user1625293
user1625293

Reputation: 45

How can I easily convert legacy code to WCF?

Hi I have the following legacy code. I would like to create a WCF without going to create all the contracts and other junk MS has built into their code. There are more then 100 commands I would have to create for every method and command. It would be simpler just to use the existing code.

 using System;
 using System.Net.Sockets;

 namespace Server
 {
class Program
{
    static void Main(string[] args)
    {
        TcpListener serverSocket = new TcpListener(55555);
        TcpClient clientSocket = default(TcpClient);
        serverSocket.Start();
        Console.WriteLine(" >> " + "Server Started");
        ServerLobby.Initialize();
        ServerLobby.reader.Load("Users.xml");

        while (true)
        {
            clientSocket = serverSocket.AcceptTcpClient();
            Client client = new Client(clientSocket);
          }
       }
    }
}

Thanks

Upvotes: 1

Views: 98

Answers (1)

ChaosPandion
ChaosPandion

Reputation: 78282

The simplest way would be to define a simple WCF interface that will call your legacy methods. You still gotta fill in all that "junk" though.

public interface ICommandServer
{
    void Execute(string command, string[] args);
}

Upvotes: 1

Related Questions