Windows Communication Foundation extensibility to the max

Last week I visited Microsoft at the Redmond campus and spent the larger part of the week with the Windows Communication Foundation and Workflow Foundation team. I spoke with a lot of the team members and managed to get good insights into the things to come in WCF/WF 4.0.

I got a chance to talk to Nicolas Allen and Kenny Wolf. Besides the work-related issues that I wanted to investigate I also discussed my long-running attempt to create a very odd WCF client implementation. They gave me a couple of hints on how to take the last hurdles to get everything working. While still shrugging off the last bits of jetlag I managed to get the first implementation up and running. Although WCF was never designed with such weird things in mind, this proves that WCF is extensible beyond your imagination. I’ll walk you through it all.

Part 1: Background on game server protocols
Part 2: The big picture
Part 3: Formatting operations
Part 4: Applying formatting to operations
Part 5: Make your endpoints behave

But, just as a teaser preview, here are some code snippets of what this will all amount to:

public interface IRcon
	[OperationContract(Action = "status")]
	string GetStatus();
	[OperationContract(Action = "changelevel")]
	string ChangeLevel(string mapName);
	[OperationContract(Action = "mp_restartround")]
	void Restart(int seconds);

public interface IRconProxy : IRcon, IClientChannel { } 

class Program
	static void Main(string[] args)
		SourceRconTcpBinding binding = new SourceRconTcpBinding("abc123");
		string uri = "raw.tcp://";
		IRconProxy proxy = null;

			ChannelFactory<IRconProxy> factory = new ChannelFactory<IRconProxy>(binding, new EndpointAddress(uri));
			factory.Endpoint.Behaviors.Add(new SourceRconEndpointBehavior());

			proxy = factory.CreateChannel();

			string reply = proxy.GetStatus();
		catch (Exception ex)

Here, the most interesting lines of code are 31 and 32: a WCF client channel talking a proprietary, non-SOAP protocol over a TCP connection.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s