package service

import (
	"common/discover"
	"common/discover/common"
	"common/proto/ss/grpc_pb"
)

func GatewayNewClient(sid ...int64) (grpc_pb.GatewayClient, error) {
	c, err := discover.FindServer(common.KeyDiscoverGateway, sid...)
	if err != nil {
		return nil, err
	}
	return grpc_pb.NewGatewayClient(c), nil
}

func GatewayNewBroadcastClient() map[int64]grpc_pb.GatewayClient {
	clientM := make(map[int64]grpc_pb.GatewayClient)
	connM := discover.FindServerAll(common.KeyDiscoverGateway)
	for sid, conn := range connM {
		clientM[sid] = grpc_pb.NewGatewayClient(conn)
	}
	return clientM
}
