
For service name I just put the name of my class with the namespace, I gave the name of the service the same name as my class, and as my contract, I created an interface that has to be present in the server and client, but in my case my assembly could be either. The interface just specified which methods could be called on my server class, and then my server class just implemented that interface. For the server I added a thread to my user interface and when a user chose to host a game it just did this:
mHostThread = New Threading.Thread(AddressOf StartHost)
mHostThread.Start()
And startHost simply did this:
mPuzzleHost = New ServiceHost(GetType(PuzzleServer))
mPuzzleHost.Open()
Having this in a thread allowed the person hosting the game to also join as a client. Then to join the game (server) as client all I had to do was this:
Dim puzzleFactory As ChannelFactory(Of IPuzzleServer) = New ChannelFactory(Of IPuzzleServer)("PuzzleServer")
puzzleFactory.Endpoint.Address = New System.ServiceModel.EndpointAddress("net.tcp://" & frm.IP & ":3315/PuzzleServer")
Try
mPuzzleProxy = puzzleFactory.CreateChannel
mPlayerId = mPuzzleProxy.JoinGame(frm.PlayerName, frm.PlayerColor)
Catch ex As Exception
MessageBox.Show("Could not connect to host '" & frm.IP & "'. Reason: " & ex.Message)
Exit Sub
End Try
I hope that makes sense, if you have any questions feel free to email me.