// Code generated by protoc-gen-go-grpc. DO NOT EDIT.

package tunnel

import (
	context "context"
	grpc "google.golang.org/grpc"
	codes "google.golang.org/grpc/codes"
	status "google.golang.org/grpc/status"
)

// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7

// TunnelClient is the client API for Tunnel service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type TunnelClient interface {
	// Client 调用此方法建立连接
	Connect(ctx context.Context, opts ...grpc.CallOption) (Tunnel_ConnectClient, error)
}

type tunnelClient struct {
	cc grpc.ClientConnInterface
}

func NewTunnelClient(cc grpc.ClientConnInterface) TunnelClient {
	return &tunnelClient{cc}
}

func (c *tunnelClient) Connect(ctx context.Context, opts ...grpc.CallOption) (Tunnel_ConnectClient, error) {
	stream, err := c.cc.NewStream(ctx, &Tunnel_ServiceDesc.Streams[0], "/tunnel.Tunnel/Connect", opts...)
	if err != nil {
		return nil, err
	}
	x := &tunnelConnectClient{stream}
	return x, nil
}

type Tunnel_ConnectClient interface {
	Send(*Request) error
	Recv() (*Response, error)
	grpc.ClientStream
}

type tunnelConnectClient struct {
	grpc.ClientStream
}

func (x *tunnelConnectClient) Send(m *Request) error {
	return x.ClientStream.SendMsg(m)
}

func (x *tunnelConnectClient) Recv() (*Response, error) {
	m := new(Response)
	if err := x.ClientStream.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}

// TunnelServer is the server API for Tunnel service.
// All implementations must embed UnimplementedTunnelServer
// for forward compatibility
type TunnelServer interface {
	// Client 调用此方法建立连接
	Connect(Tunnel_ConnectServer) error
	mustEmbedUnimplementedTunnelServer()
}

// UnimplementedTunnelServer must be embedded to have forward compatible implementations.
type UnimplementedTunnelServer struct {
}

func (UnimplementedTunnelServer) Connect(Tunnel_ConnectServer) error {
	return status.Errorf(codes.Unimplemented, "method Connect not implemented")
}
func (UnimplementedTunnelServer) mustEmbedUnimplementedTunnelServer() {}

// UnsafeTunnelServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to TunnelServer will
// result in compilation errors.
type UnsafeTunnelServer interface {
	mustEmbedUnimplementedTunnelServer()
}

func RegisterTunnelServer(s grpc.ServiceRegistrar, srv TunnelServer) {
	s.RegisterService(&Tunnel_ServiceDesc, srv)
}

func _Tunnel_Connect_Handler(srv interface{}, stream grpc.ServerStream) error {
	return srv.(TunnelServer).Connect(&tunnelConnectServer{stream})
}

type Tunnel_ConnectServer interface {
	Send(*Response) error
	Recv() (*Request, error)
	grpc.ServerStream
}

type tunnelConnectServer struct {
	grpc.ServerStream
}

func (x *tunnelConnectServer) Send(m *Response) error {
	return x.ServerStream.SendMsg(m)
}

func (x *tunnelConnectServer) Recv() (*Request, error) {
	m := new(Request)
	if err := x.ServerStream.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}

// Tunnel_ServiceDesc is the grpc.ServiceDesc for Tunnel service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Tunnel_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "tunnel.Tunnel",
	HandlerType: (*TunnelServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Connect",
			Handler:       _Tunnel_Connect_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "tunnel/tunnel.proto",
}
