diff --git a/.default.nix.swp b/.default.nix.swp new file mode 100644 index 0000000..6d891d2 Binary files /dev/null and b/.default.nix.swp differ diff --git a/Bindings/Client.go b/Bindings/Client.go index 18fc0bc..4d6318e 100644 --- a/Bindings/Client.go +++ b/Bindings/Client.go @@ -5,6 +5,7 @@ import ( "encoding/json" "github.com/Akilan1999/p2p-rendering-computation/abstractions" "github.com/Akilan1999/p2p-rendering-computation/client" + "github.com/Akilan1999/p2p-rendering-computation/server" ) // The Client package where data-types @@ -13,41 +14,51 @@ import ( // be export //export StartContainer -func StartContainer(IP string, NumPorts int, GPU bool, ContainerName string, baseImage string) (output string) { +func StartContainer(IP string, NumPorts int, GPU bool, ContainerName string, baseImage string) (output *C.char) { container, err := client.StartContainer(IP, NumPorts, GPU, ContainerName, baseImage) if err != nil { - return err.Error() + return C.CString(err.Error()) } return ConvertStructToJSONString(container) } //export GetSpecs -func GetSpecs(IP string) (output string) { +func GetSpecs(IP string) (output *C.char) { specs, err := client.GetSpecs(IP) if err != nil { - return err.Error() + return C.CString(err.Error()) } return ConvertStructToJSONString(specs) } //export Init -func Init(customConfig string) (output string) { +func Init(customConfig string) (output *C.char) { init, err := abstractions.Init(customConfig) if err != nil { - return err.Error() + return C.CString(err.Error()) } return ConvertStructToJSONString(init) } -func ConvertStructToJSONString(Struct interface{}) string { +//export Server +func Server() (output *C.char) { + _, err := server.Server() + if err != nil { + return C.CString(err.Error()) + } + + return ConvertStructToJSONString("") +} + +func ConvertStructToJSONString(Struct interface{}) *C.char { jsonBytes, err := json.Marshal(Struct) if err != nil { - return err.Error() + return C.CString(err.Error()) } // Convert the JSON bytes to a string - return string(jsonBytes) + return C.CString(string(jsonBytes)) } func main() {}