service

package
v0.0.0-...-12eefb5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package service contains various gRPC service implementations used by the voip server. Each one should implement both the generated and server.Service interfaces to be registered against the gRPC server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Audio

type Audio struct {
	// contains filtered or unexported fields
}

The Audio type is a server.Service implementation that handles streaming of audio to/from clients.

func NewAudioService

func NewAudioService(sb Switchboard, channels ChannelRepository) *Audio

NewAudioService creates a new Audio instance that will use the provided switchboard implementation to direct audio data among clients.

func (*Audio) Register

func (svc *Audio) Register(svr *grpc.Server)

Register the service on the server.

func (*Audio) Stream

func (svc *Audio) Stream(stream audio.AudioService_StreamServer) error

Stream audio data bidirectionally. Writes audio data from the client to all members of their current channel. Reads audio data from the client's current channel and writes it to the client.

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

The Auth type is a server.Service implementation that handles inbound gRPC calls regarding authorization of users.

func NewAuthService

func NewAuthService(users UserRepository, tokens TokenManager) *Auth

NewAuthService creates a new Auth instance that uses the provided interface implementations to manage user data and generate authorization tokens.

func (*Auth) CreateUser

func (svc *Auth) CreateUser(ctx context.Context, r *auth.CreateUserRequest) (*auth.CreateUserResponse, error)

CreateUser handles an inbound gRPC request that attempts to create a new user.

func (*Auth) Login

func (svc *Auth) Login(ctx context.Context, r *auth.LoginRequest) (*auth.LoginResponse, error)

Login handles an inbound gRPC call attempting to authenticate a user. If successful, returns a token that can be used to authenticate subsequent calls to the server.

func (*Auth) Register

func (svc *Auth) Register(svr *grpc.Server)

Register the service on the server

type ChannelRepository

type ChannelRepository interface {
	List(ctx context.Context) ([]string, error)
	Create(ctx context.Context, name string) error
	Exists(ctx context.Context, name string) (bool, error)
	Delete(ctx context.Context, name string) error
	GetUserChannel(ctx context.Context, name string) (string, error)
	Users(ctx context.Context, name string) ([]string, error)
	Join(ctx context.Context, name, channel string) error
	Leave(ctx context.Context, user, name string) error
}

The ChannelRepository interface describes types that can manage and query channels.

type Channels

type Channels struct {
	// contains filtered or unexported fields
}

The Channels type is a server.Service implementation that handles inbound gRPC request to manage audio channels that clients can use.

func NewChannelService

func NewChannelService(channels ChannelRepository) *Channels

NewChannelService creates a new Channel instance that uses the provided repository implementation to persist/query channel data.

func (*Channels) Create

func (svc *Channels) Create(ctx context.Context, r *channel.CreateRequest) (*channel.CreateResponse, error)

Create handles an inbound gRPC request to create a new channel.

func (*Channels) Delete

func (svc *Channels) Delete(ctx context.Context, r *channel.DeleteRequest) (*channel.DeleteResponse, error)

Delete handles an inbound gRPC request to delete a channel.

func (*Channels) Join

func (svc *Channels) Join(ctx context.Context, r *channel.JoinRequest) (*channel.JoinResponse, error)

Join handles an inbound gRPC request to move a user to a channel. This updates the servers reference of who is where, in order to move fully, the client must disconnect and reconnect their audio stream.

func (*Channels) Leave

func (svc *Channels) Leave(ctx context.Context, _ *channel.LeaveRequest) (*channel.LeaveResponse, error)

Leave handles an inbound gRPC request to remove a user from a channel. On a successful response, the audio stream should be stopped by the client.

func (*Channels) List

func (svc *Channels) List(ctx context.Context, _ *channel.ListRequest) (*channel.ListResponse, error)

List handles an inbound gRPC request to list all available channels.

func (*Channels) Register

func (svc *Channels) Register(svr *grpc.Server)

Register the service on the server.

func (*Channels) Users

func (svc *Channels) Users(ctx context.Context, r *channel.UsersRequest) (*channel.UsersResponse, error)

Users handles an inbound gRPC request to list all users who are in a channel.

type Switchboard

type Switchboard interface {
	Channel(name string) (*switchboard.Channel, error)
}

The Switchboard interface describes types that handle the in-memory switchboard to route audio data between clients.

type TokenManager

type TokenManager interface {
	New(user string) (token.Token, error)
}

The TokenManager interface describes types that can generate JWT tokens for use in client authorization.

type UserRepository

type UserRepository interface {
	Create(ctx context.Context, user, pass string) error
	GetPasswordHash(ctx context.Context, user string) ([]byte, error)
	Exists(ctx context.Context, name string) (bool, error)
}

The UserRepository interface describes types that manage user data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL