المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : 'Basic' Client /Server



C# Programming
02-23-2010, 08:11 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 response

I 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.