Starlight-30036225 / ChessTCP

FILLMELATER
0 stars 0 forks source link

Basic 2 way communication #1

Closed Starlight-30036225 closed 10 months ago

Starlight-30036225 commented 10 months ago

https://www.youtube.com/watch?v=hIc_9Wbn704

Using the video marked above I intend to create a basic two way communication service that will be used later for the game.

For now I will not bother with packets, just creating the server and client sockets and allowing them to send arbitrary data is a solid enough start.

This should also give me the frame work for multiple clients, which can be later expanded into chat rooms and spectators.

Starlight-30036225 commented 10 months ago

I have created the basic server class. Currently, there is no client for it to connect too but it should be functionally sound.

image This snippet is creates a connection with an incoming client, binds it to the connection handler class and places it in the thread pool so the server can focus on incoming connections.

Inside the ConnectionHandler class: image

Now when a client is bound to the Connection handler, it will be sent a request for its nickname (Just a tester will be changed later), then print the nickname. Then send a welcome message with the applied nickname.

This will make a quick test when the client side is built

Starlight-30036225 commented 10 months ago

I chose to differ from the video for the client class, the creator elected to use a seperate thread to read inputs, I do not think this is currently necessary so I am simplifying it. image This simply returns any received messages to the server.

So the clients 'nickname' should be "Enter a nickname"

Time to test it.

Starlight-30036225 commented 10 months ago

image Perfect.

This is a very simple connection, but its a start. Ill comment this and close this issue.