http - concept for c# web server for browser game client -


as student, have recieved task of making connect 4 game. task code simple c# web server listens http requests 2 players can play against eachother, 1 in c#c form, 1 in website.

but i'm confused on how such thing work. have web client design of game , it's behaviour , data out of c# code. c# server should use httplistener, httplistenerrequest , httplistenercontext classes.

i'm unsure on how such thing. appreciated on how start task, i'm unclear see accomplish it.

greetings, durneztj

you need 6 projects

1: winforms - connect 4 client

2: web application - connect 4 client

3: winforms - connect 4 server (for points make windows service or web api project)

4: class library - connect 4 game logic , models

5: test project 4

6: class lib - client code connecting 3

do class lib first. put models , game logic in here expose single class methods starting game, making move , working out if won. make interface class.

write tests in test project make sure have basic game logic right, can start game , make moves etc works

then move on server. should refernce class lib , handle http listening , response etc. you'll need put connection handling , deserializing of model objects in here, exposing same methods class lib

now six. reference model class lib again , inherit same interface, time instead of starting game or making move teh game logic, connect server , call start , game, make move etc. again have deserialize response model objects.

now 1 , 2. these both similar in reference models class lib , client code lib. haev present board user differntly of course, when make move, start game etc call methods in client class lib, server execute logic , return result

for points use async task methods on everything

if doesn't work, write integration tests server. these save hours of working out whether client or server buggy

another point tip, use microsoft unity framework dependency injection


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -