Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
Debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
DeerFrog committed Nov 3, 2024
1 parent 56ba8bd commit 90ecb5d
Show file tree
Hide file tree
Showing 15 changed files with 224 additions and 173 deletions.
Binary file added Client
Binary file not shown.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
all:
go build ./src/Server/Server.go
go build ./src/Client/Client.go

clean:
rm -f ./Server ./Client

Binary file added Server
Binary file not shown.
3 changes: 3 additions & 0 deletions docs/assets/ClassDiagram Client.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/assets/ClassDiagram Server.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/assets/SequenceDiagram 1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/assets/SequenceDiagram 2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
10 changes: 5 additions & 5 deletions src/Client/ATM/ATM.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import (
)

type AccountAccessRequest struct {
ID int64
ID int
Password string
}

type FundsOperationRequest struct {
ID int64
ID int
Password string
Quantity float64
}

func Withdraw(id int64, password string, quantity float64) func(*rpc.Client) error {
func Withdraw(id int, password string, quantity float64) func(*rpc.Client) error {
return func(client *rpc.Client) error {
request := FundsOperationRequest{id, password, quantity}

Expand All @@ -31,7 +31,7 @@ func Withdraw(id int64, password string, quantity float64) func(*rpc.Client) err
}
}

func Deposit(id int64, password string, quantity float64) func(*rpc.Client) error {
func Deposit(id int, password string, quantity float64) func(*rpc.Client) error {
return func(client *rpc.Client) error {
request := FundsOperationRequest{id, password, quantity}

Expand All @@ -46,7 +46,7 @@ func Deposit(id int64, password string, quantity float64) func(*rpc.Client) erro
}
}

func CheckBalance(id int64, password string) func(*rpc.Client) error {
func CheckBalance(id int, password string) func(*rpc.Client) error {
return func(client *rpc.Client) error {
request := AccountAccessRequest{id, password}

Expand Down
14 changes: 7 additions & 7 deletions src/Client/BankBranch/BankBranch.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ type OpenAccountRequest struct {
}

type AccountAccessRequest struct {
ID int64
ID int
Password string
}

type FundsOperationRequest struct {
ID int64
ID int
Password string
Quantity float64
}
Expand All @@ -25,7 +25,7 @@ func OpenNewAccount(name string, password string) func(*rpc.Client) error {
return func(client *rpc.Client) error {
request := OpenAccountRequest{name, password}

var response int64
var response int

err := client.Call("Bank.OpenAccount", request, &response)
if err != nil {
Expand All @@ -36,7 +36,7 @@ func OpenNewAccount(name string, password string) func(*rpc.Client) error {
}
}

func CloseAccount(id int64, password string) func(*rpc.Client) error {
func CloseAccount(id int, password string) func(*rpc.Client) error {
return func(client *rpc.Client) error {
request := AccountAccessRequest{id, password}

Expand All @@ -51,7 +51,7 @@ func CloseAccount(id int64, password string) func(*rpc.Client) error {
}
}

func Withdraw(id int64, password string, quantity float64) func(*rpc.Client) error {
func Withdraw(id int, password string, quantity float64) func(*rpc.Client) error {
return func(client *rpc.Client) error {
request := FundsOperationRequest{id, password, quantity}

Expand All @@ -66,7 +66,7 @@ func Withdraw(id int64, password string, quantity float64) func(*rpc.Client) err
}
}

func Deposit(id int64, password string, quantity float64) func(*rpc.Client) error {
func Deposit(id int, password string, quantity float64) func(*rpc.Client) error {
return func(client *rpc.Client) error {
request := FundsOperationRequest{id, password, quantity}

Expand All @@ -81,7 +81,7 @@ func Deposit(id int64, password string, quantity float64) func(*rpc.Client) erro
}
}

func CheckBalance(id int64, password string) func(*rpc.Client) error {
func CheckBalance(id int, password string) func(*rpc.Client) error {
return func(client *rpc.Client) error {
request := AccountAccessRequest{id, password}

Expand Down
23 changes: 22 additions & 1 deletion src/Client/Client.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
package Client
package main

import (
"Coinnect-FPPD/src/Menu"
Pygmalion "Coinnect-FPPD/src/deps"
"fmt"
"net/rpc"
)

func main() {
// Carrega configurações
Pygmalion.InitConfigReader("settings.yml", ".")
port := Pygmalion.ReadInteger("ServerPort")
address := Pygmalion.ReadString("ServerAddr")
fmt.Printf("Client.main : Initializing Client : ServerAddress=%s, ServerPort=%d\n", address, port)

for {
// Executa uma operação
callback := Menu.ObtainClientOperation()
if callback != nil {
// Executa a chamada ao servidor
SendOperation(address, port, callback)
continue
}
break
}
}

func SendOperation(serverAddress string, serverPort int, callback func(*rpc.Client) error) {
// Tenta uma conexão TCP com o banco
client, err := rpc.Dial("tcp", fmt.Sprintf("%s:%d", serverAddress, serverPort))
Expand Down
Loading

0 comments on commit 90ecb5d

Please sign in to comment.