package main

import (
	"ShotRDP/client"
	"context"
	"google.golang.org/grpc"
	"net"

	"ShotRDP/pb"
)

type Server struct {
	pb.UnimplementedGetScreenServer
}

func (server *Server) GetScreen(ctx context.Context, in *pb.Request) (*pb.Response, error) {
	imgBytes, err := client.RealGetScreen(in.GetHost(), 1024, 800)
	return &pb.Response{ImageBytes: imgBytes}, err
}

func main() {
	listener, err := net.Listen("tcp", ":8972")
	if err != nil {
		panic(err)
	}

	server := grpc.NewServer()
	pb.RegisterGetScreenServer(server, &Server{})

	err = server.Serve(listener)
	if err != nil {
		panic(err)
	}
}
