[PD1] Structured client.
Still need to create crypto object and use it to encrypt messages Need to create TLS still
This commit is contained in:
parent
278b8e1a73
commit
cdaae8fb7e
9 changed files with 252 additions and 110 deletions
|
@ -3,19 +3,14 @@ package server
|
|||
import (
|
||||
"PD1/internal/protocol"
|
||||
"PD1/internal/utils/networking"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func clientHandler(connection networking.Connection[protocol.Packet]) {
|
||||
defer connection.Conn.Close()
|
||||
|
||||
jd := json.NewDecoder(connection.Conn)
|
||||
defer connection.Conn.Close()
|
||||
|
||||
for {
|
||||
var pac protocol.Packet
|
||||
jd.Decode(&pac)
|
||||
|
||||
pac := connection.Receive()
|
||||
switch pac.Flag {
|
||||
case protocol.ReqPK:
|
||||
fmt.Println("ReqPK")
|
||||
|
@ -24,7 +19,7 @@ func clientHandler(connection networking.Connection[protocol.Packet]) {
|
|||
case protocol.ReqMsg:
|
||||
fmt.Println("ReqMsg")
|
||||
case protocol.SubmitMsg:
|
||||
fmt.Println("SubmitMsh")
|
||||
fmt.Println("SubmitMsg")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +30,7 @@ func Run(port int) {
|
|||
go server.ListenLoop()
|
||||
|
||||
for {
|
||||
//Receive connection via channel
|
||||
//Receive Connection via channel
|
||||
conn := <-server.C
|
||||
//Launch client handler via clientHandler
|
||||
go clientHandler(conn)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue