package server

import (
	"common/discover/common"
	"common/net/grpc/service"
	"common/proto/ss/grpc_pb"
	"gateway/internal/handler/ws_handler"
	"google.golang.org/grpc"
)

type Server struct {
	grpc_pb.UnimplementedGatewayServer
	service.Base
}

func NewServer(ttl int64) *Server {
	s := &Server{
		Base: service.Base{
			Target:  common.KeyDiscoverGateway,
			EtcdTTL: ttl,
		},
	}
	s.Base.OnInit = s.OnInit
	s.Base.OnClose = s.OnClose
	return s
}

func (s *Server) OnInit(serve *grpc.Server) {
	ws_handler.GatewaySID = s.SID
	grpc_pb.RegisterGatewayServer(serve, s)
}

func (s *Server) OnClose() {
}
