'Basic' Client /Server
-
Been looking for quite some time for the answer to my question. How do I do this in C#:
//Note: Pseudo Code for example purposes only...
[Client]
SendToServer(ClientActions.Login, username, password);[Server]
ReceiveRequest(Tag, pram1, pram2);
if (tag == ClientActions.Login)
{
bool exUser = UserExist(pram1, pram2);
if (exUser)
SendToClient(ServerAction.Exist);
else
SendToClient(ServerAction.NotExist);
}[Client]
ReceiveResponse(Response);
if (Response == ServerAction.Exist)
// Display message of response
else
// Display message of responseI am trying to setup a MultiPerson game using C# as my primary. Currently I have the client access the database directly because I have found no tutorials explaining how to this sort of thing. Mostly I have found Chat servers which do not help me figure this problem out. I have been able to do the above using alternate means, but since I will need to do more than send a few simple strings, I have no clue how to do it... My main issue is figuring out how to get both the client and the server to know how to deal with whatever comes down the pipe. My progression after the above would have been to ask the server for the userdata and have the server send a List object back. But I don't know how to do it. I would appreciate any and all help for this.
-
Been looking for quite some time for the answer to my question. How do I do this in C#:
//Note: Pseudo Code for example purposes only...
[Client]
SendToServer(ClientActions.Login, username, password);[Server]
ReceiveRequest(Tag, pram1, pram2);
if (tag == ClientActions.Login)
{
bool exUser = UserExist(pram1, pram2);
if (exUser)
SendToClient(ServerAction.Exist);
else
SendToClient(ServerAction.NotExist);
}[Client]
ReceiveResponse(Response);
if (Response == ServerAction.Exist)
// Display message of response
else
// Display message of responseI am trying to setup a MultiPerson game using C# as my primary. Currently I have the client access the database directly because I have found no tutorials explaining how to this sort of thing. Mostly I have found Chat servers which do not help me figure this problem out. I have been able to do the above using alternate means, but since I will need to do more than send a few simple strings, I have no clue how to do it... My main issue is figuring out how to get both the client and the server to know how to deal with whatever comes down the pipe. My progression after the above would have been to ask the server for the userdata and have the server send a List object back. But I don't know how to do it. I would appreciate any and all help for this.
Use Remoting or WCF. You can create your own method and your own object for sending/receiving. Remoting : http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=62[^] WCF : http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication[^]
-
Been looking for quite some time for the answer to my question. How do I do this in C#:
//Note: Pseudo Code for example purposes only...
[Client]
SendToServer(ClientActions.Login, username, password);[Server]
ReceiveRequest(Tag, pram1, pram2);
if (tag == ClientActions.Login)
{
bool exUser = UserExist(pram1, pram2);
if (exUser)
SendToClient(ServerAction.Exist);
else
SendToClient(ServerAction.NotExist);
}[Client]
ReceiveResponse(Response);
if (Response == ServerAction.Exist)
// Display message of response
else
// Display message of responseI am trying to setup a MultiPerson game using C# as my primary. Currently I have the client access the database directly because I have found no tutorials explaining how to this sort of thing. Mostly I have found Chat servers which do not help me figure this problem out. I have been able to do the above using alternate means, but since I will need to do more than send a few simple strings, I have no clue how to do it... My main issue is figuring out how to get both the client and the server to know how to deal with whatever comes down the pipe. My progression after the above would have been to ask the server for the userdata and have the server send a List object back. But I don't know how to do it. I would appreciate any and all help for this.
As said, use Remoting or WCF. But, you will not: SendToServer And then ReceiveResponse You will: CallMethod(parameters) And such method can have a return type, so you get the response automatically.
-
Been looking for quite some time for the answer to my question. How do I do this in C#:
//Note: Pseudo Code for example purposes only...
[Client]
SendToServer(ClientActions.Login, username, password);[Server]
ReceiveRequest(Tag, pram1, pram2);
if (tag == ClientActions.Login)
{
bool exUser = UserExist(pram1, pram2);
if (exUser)
SendToClient(ServerAction.Exist);
else
SendToClient(ServerAction.NotExist);
}[Client]
ReceiveResponse(Response);
if (Response == ServerAction.Exist)
// Display message of response
else
// Display message of responseI am trying to setup a MultiPerson game using C# as my primary. Currently I have the client access the database directly because I have found no tutorials explaining how to this sort of thing. Mostly I have found Chat servers which do not help me figure this problem out. I have been able to do the above using alternate means, but since I will need to do more than send a few simple strings, I have no clue how to do it... My main issue is figuring out how to get both the client and the server to know how to deal with whatever comes down the pipe. My progression after the above would have been to ask the server for the userdata and have the server send a List object back. But I don't know how to do it. I would appreciate any and all help for this.
-
Been looking for quite some time for the answer to my question. How do I do this in C#:
//Note: Pseudo Code for example purposes only...
[Client]
SendToServer(ClientActions.Login, username, password);[Server]
ReceiveRequest(Tag, pram1, pram2);
if (tag == ClientActions.Login)
{
bool exUser = UserExist(pram1, pram2);
if (exUser)
SendToClient(ServerAction.Exist);
else
SendToClient(ServerAction.NotExist);
}[Client]
ReceiveResponse(Response);
if (Response == ServerAction.Exist)
// Display message of response
else
// Display message of responseI am trying to setup a MultiPerson game using C# as my primary. Currently I have the client access the database directly because I have found no tutorials explaining how to this sort of thing. Mostly I have found Chat servers which do not help me figure this problem out. I have been able to do the above using alternate means, but since I will need to do more than send a few simple strings, I have no clue how to do it... My main issue is figuring out how to get both the client and the server to know how to deal with whatever comes down the pipe. My progression after the above would have been to ask the server for the userdata and have the server send a List object back. But I don't know how to do it. I would appreciate any and all help for this.
Okay, so WCF is the way to go. And, as I said, it is Pseudo code. ^_^ It shows what I expect the server to do, not exactly what it will do. So, how would I go about using WCF with my example as the start? IE a simple Return of a Bool... I just need to see an example that doesn't rely on a string... ^_^ One more thing. How do you get it to listen for more than one thing. I would think it would have to do with the Channel... But not sure. Thank you for your prior help and for any further help you can provide. Nevermind, I figured it out, I think. You just add more Functions to the Interface... Now I just need to find a cheap Windows Server to test it on... EDIT:: I can't seem to get it to report errors other than System.ServiceModel errors. I missed a MySQL error because All I got from the Debugger was that an Internal error occurred... Not a big deal, but a bit annoying...
modified on Monday, February 22, 2010 8:18 PM
-
Been looking for quite some time for the answer to my question. How do I do this in C#:
//Note: Pseudo Code for example purposes only...
[Client]
SendToServer(ClientActions.Login, username, password);[Server]
ReceiveRequest(Tag, pram1, pram2);
if (tag == ClientActions.Login)
{
bool exUser = UserExist(pram1, pram2);
if (exUser)
SendToClient(ServerAction.Exist);
else
SendToClient(ServerAction.NotExist);
}[Client]
ReceiveResponse(Response);
if (Response == ServerAction.Exist)
// Display message of response
else
// Display message of responseI am trying to setup a MultiPerson game using C# as my primary. Currently I have the client access the database directly because I have found no tutorials explaining how to this sort of thing. Mostly I have found Chat servers which do not help me figure this problem out. I have been able to do the above using alternate means, but since I will need to do more than send a few simple strings, I have no clue how to do it... My main issue is figuring out how to get both the client and the server to know how to deal with whatever comes down the pipe. My progression after the above would have been to ask the server for the userdata and have the server send a List object back. But I don't know how to do it. I would appreciate any and all help for this.
Seems I do need more help after all. I have 2 main issues. The first is that I get different results when using the .NET 3.5 Framework and the .NET 4.0 Framework. The app functions correctly in 4.0 but returns a few odd things in 3.5. While all in all it doesn't matter, I'm using 4.0 as the primary anyway, it does pose a problem on the end-user. 3.5 is standard but 4.0 is in beta4 so most will not touch it. My second problem is this:
System.ServiceModel.CommunicationObjectFaultedException: The communication object,
System.ServiceModel.ServiceHost, cannot be used for communication because it is in the Faulted state.
at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.ServiceHostBase.System.IDisposable.Dispose()
at Impur.Game.Network.Server.Program.Main(String[] args)Now, I understand the error. It is because I went the Using route when making my ServiceHost. My problem is that I don't know hot to do it another way. Now, my app works perfectly on my computer, but gives that error on my Dev Tester's computer. Here is the code I use. Maybe you can tell me how to do it another way:
using (ServiceHost host = new ServiceHost( typeof(Actions), new Uri\[\]{ new Uri("http://localhost:8000"), new Uri("net.pipe://localhost") }))
EDIT:: Fixed the Second problem and have now encountered:
System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL http://+:8000/. Your
process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353
for details). ---> System.Net.HttpListenerException: Access is deniedThis one I have no clue about.