comm

package
v0.0.0-...-8876515 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package comm contains functions and types from communication between music-sync clients and the server

Package comm is a generated protocol buffer package.

It is generated from these files:

comm/packages.proto

It has these top-level messages:

Envelope
TimeSyncRequest
TimeSyncResponse
QueueChunkRequest
PingMessage
PongMessage
SetVolumeRequest
SubscribeChannelRequest
NewSongInfo
ChunkInfo
PauseInfo

Index

Constants

This section is empty.

Variables

View Source
var Channel_name = map[int32]string{
	0: "AUDIO",
	1: "META",
}
View Source
var Channel_value = map[string]int32{
	"AUDIO": 0,
	"META":  1,
}
View Source
var NewClientHandler func(channel Channel, conn MessageSender)

NewClientHandler is called when a new client connects to the server (with channel -1) and when a client subscribes to a channel.

Functions

func PingHandler

func PingHandler(conn net.Conn)

PingHandler handle a PingMessage

Types

type BaseTypedPackageHandler

type BaseTypedPackageHandler struct{}

BaseTypedPackageHandler implements all TypedPackageHandlerInterface methods without doing anything

func (BaseTypedPackageHandler) HandleChunkInfo

func (BaseTypedPackageHandler) HandleChunkInfo(*ChunkInfo, net.Conn)

HandleChunkInfo is called to handle ChunkInfo

func (BaseTypedPackageHandler) HandleNewSongInfo

func (BaseTypedPackageHandler) HandleNewSongInfo(*NewSongInfo, net.Conn)

HandleNewSongInfo is called to handle NewSongInfo

func (BaseTypedPackageHandler) HandlePauseInfo

func (BaseTypedPackageHandler) HandlePauseInfo(*PauseInfo, net.Conn)

HandlePauseInfo is called to handle PauseInfo

func (BaseTypedPackageHandler) HandlePingMessage

func (BaseTypedPackageHandler) HandlePingMessage(*PingMessage, net.Conn)

HandlePingMessage is called to handle a PingMessage

func (BaseTypedPackageHandler) HandlePongMessage

func (BaseTypedPackageHandler) HandlePongMessage(*PongMessage, net.Conn)

HandlePongMessage is called to handle a PongMessage

func (BaseTypedPackageHandler) HandleQueueChunkRequest

func (BaseTypedPackageHandler) HandleQueueChunkRequest(*QueueChunkRequest, net.Conn)

HandleQueueChunkRequest is called to handle a QueueChunkRequest

func (BaseTypedPackageHandler) HandleSetVolumeRequest

func (BaseTypedPackageHandler) HandleSetVolumeRequest(*SetVolumeRequest, net.Conn)

HandleSetVolumeRequest is called to handle a SetVolumeRequest

func (BaseTypedPackageHandler) HandleSubscribeChannelRequest

func (BaseTypedPackageHandler) HandleSubscribeChannelRequest(*SubscribeChannelRequest, net.Conn)

HandleSubscribeChannelRequest is called to handle a SubscribeChannelRequest

func (BaseTypedPackageHandler) HandleTimeSyncRequest

func (BaseTypedPackageHandler) HandleTimeSyncRequest(*TimeSyncRequest, net.Conn)

HandleTimeSyncRequest is called to handle a TimeSyncRequest

func (BaseTypedPackageHandler) HandleTimeSyncResponse

func (BaseTypedPackageHandler) HandleTimeSyncResponse(*TimeSyncResponse, net.Conn)

HandleTimeSyncResponse is called to handle a TimeSyncResponse

type Channel

type Channel int32
const (
	Channel_AUDIO Channel = 0
	Channel_META  Channel = 1
)

func (Channel) EnumDescriptor

func (Channel) EnumDescriptor() ([]byte, []int)

func (Channel) String

func (x Channel) String() string

type ChunkInfo

type ChunkInfo struct {
	StartTime        int64  `protobuf:"varint,1,opt,name=startTime" json:"startTime,omitempty"`
	FirstSampleIndex uint64 `protobuf:"varint,2,opt,name=firstSampleIndex" json:"firstSampleIndex,omitempty"`
	ChunkSize        uint64 `protobuf:"varint,3,opt,name=chunkSize" json:"chunkSize,omitempty"`
}

func (*ChunkInfo) Descriptor

func (*ChunkInfo) Descriptor() ([]byte, []int)

func (*ChunkInfo) GetChunkSize

func (m *ChunkInfo) GetChunkSize() uint64

func (*ChunkInfo) GetFirstSampleIndex

func (m *ChunkInfo) GetFirstSampleIndex() uint64

func (*ChunkInfo) GetStartTime

func (m *ChunkInfo) GetStartTime() int64

func (*ChunkInfo) ProtoMessage

func (*ChunkInfo) ProtoMessage()

func (*ChunkInfo) Reset

func (m *ChunkInfo) Reset()

func (*ChunkInfo) String

func (m *ChunkInfo) String() string

type Envelope

type Envelope struct {
	Type string `protobuf:"bytes,1,opt,name=type" json:"type,omitempty"`
	Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
}

func (*Envelope) Descriptor

func (*Envelope) Descriptor() ([]byte, []int)

func (*Envelope) GetData

func (m *Envelope) GetData() []byte

func (*Envelope) GetType

func (m *Envelope) GetType() string

func (*Envelope) ProtoMessage

func (*Envelope) ProtoMessage()

func (*Envelope) Reset

func (m *Envelope) Reset()

func (*Envelope) String

func (m *Envelope) String() string

type MessageSender

type MessageSender interface {
	// Sends a message to the server/all clients.
	// This method respects subscribe message from clients.
	SendMessage(m proto.Message) error
}

MessageSender is an interface used to send protobuf messages to clients/the server.

func ConnectToServer

func ConnectToServer(master string, handler TypedPackageHandler) (MessageSender, error)

ConnectToServer connects to the server at server and returns a MessageSender to communicate with the master

func StartServer

func StartServer(address string) (MessageSender, error)

StartServer starts a music-sync server listening at address and returns a MessageSender to broadcast to clients

type NewSongInfo

type NewSongInfo struct {
	FirstSampleOfSongIndex uint64                        `protobuf:"varint,1,opt,name=firstSampleOfSongIndex" json:"firstSampleOfSongIndex,omitempty"`
	SongFileName           string                        `protobuf:"bytes,2,opt,name=songFileName" json:"songFileName,omitempty"`
	SongLength             int64                         `protobuf:"varint,3,opt,name=songLength" json:"songLength,omitempty"`
	Lyrics                 []*NewSongInfo_SongLyricsLine `protobuf:"bytes,4,rep,name=lyrics" json:"lyrics,omitempty"`
	Metadata               *NewSongInfo_SongMetadata     `protobuf:"bytes,5,opt,name=metadata" json:"metadata,omitempty"`
}

func (*NewSongInfo) Descriptor

func (*NewSongInfo) Descriptor() ([]byte, []int)

func (*NewSongInfo) GetFirstSampleOfSongIndex

func (m *NewSongInfo) GetFirstSampleOfSongIndex() uint64

func (*NewSongInfo) GetLyrics

func (m *NewSongInfo) GetLyrics() []*NewSongInfo_SongLyricsLine

func (*NewSongInfo) GetMetadata

func (m *NewSongInfo) GetMetadata() *NewSongInfo_SongMetadata

func (*NewSongInfo) GetSongFileName

func (m *NewSongInfo) GetSongFileName() string

func (*NewSongInfo) GetSongLength

func (m *NewSongInfo) GetSongLength() int64

func (*NewSongInfo) ProtoMessage

func (*NewSongInfo) ProtoMessage()

func (*NewSongInfo) Reset

func (m *NewSongInfo) Reset()

func (*NewSongInfo) String

func (m *NewSongInfo) String() string

type NewSongInfo_SongLyricsAtom

type NewSongInfo_SongLyricsAtom struct {
	Timestamp int64  `protobuf:"varint,1,opt,name=timestamp" json:"timestamp,omitempty"`
	Caption   string `protobuf:"bytes,2,opt,name=caption" json:"caption,omitempty"`
}

func (*NewSongInfo_SongLyricsAtom) Descriptor

func (*NewSongInfo_SongLyricsAtom) Descriptor() ([]byte, []int)

func (*NewSongInfo_SongLyricsAtom) GetCaption

func (m *NewSongInfo_SongLyricsAtom) GetCaption() string

func (*NewSongInfo_SongLyricsAtom) GetTimestamp

func (m *NewSongInfo_SongLyricsAtom) GetTimestamp() int64

func (*NewSongInfo_SongLyricsAtom) ProtoMessage

func (*NewSongInfo_SongLyricsAtom) ProtoMessage()

func (*NewSongInfo_SongLyricsAtom) Reset

func (m *NewSongInfo_SongLyricsAtom) Reset()

func (*NewSongInfo_SongLyricsAtom) String

func (m *NewSongInfo_SongLyricsAtom) String() string

type NewSongInfo_SongLyricsLine

type NewSongInfo_SongLyricsLine struct {
	Atoms []*NewSongInfo_SongLyricsAtom `protobuf:"bytes,1,rep,name=atoms" json:"atoms,omitempty"`
}

func (*NewSongInfo_SongLyricsLine) Descriptor

func (*NewSongInfo_SongLyricsLine) Descriptor() ([]byte, []int)

func (*NewSongInfo_SongLyricsLine) GetAtoms

func (*NewSongInfo_SongLyricsLine) ProtoMessage

func (*NewSongInfo_SongLyricsLine) ProtoMessage()

func (*NewSongInfo_SongLyricsLine) Reset

func (m *NewSongInfo_SongLyricsLine) Reset()

func (*NewSongInfo_SongLyricsLine) String

func (m *NewSongInfo_SongLyricsLine) String() string

type NewSongInfo_SongMetadata

type NewSongInfo_SongMetadata struct {
	Title  string `protobuf:"bytes,1,opt,name=Title" json:"Title,omitempty"`
	Artist string `protobuf:"bytes,2,opt,name=Artist" json:"Artist,omitempty"`
	Album  string `protobuf:"bytes,3,opt,name=Album" json:"Album,omitempty"`
}

func (*NewSongInfo_SongMetadata) Descriptor

func (*NewSongInfo_SongMetadata) Descriptor() ([]byte, []int)

func (*NewSongInfo_SongMetadata) GetAlbum

func (m *NewSongInfo_SongMetadata) GetAlbum() string

func (*NewSongInfo_SongMetadata) GetArtist

func (m *NewSongInfo_SongMetadata) GetArtist() string

func (*NewSongInfo_SongMetadata) GetTitle

func (m *NewSongInfo_SongMetadata) GetTitle() string

func (*NewSongInfo_SongMetadata) ProtoMessage

func (*NewSongInfo_SongMetadata) ProtoMessage()

func (*NewSongInfo_SongMetadata) Reset

func (m *NewSongInfo_SongMetadata) Reset()

func (*NewSongInfo_SongMetadata) String

func (m *NewSongInfo_SongMetadata) String() string

type PauseInfo

type PauseInfo struct {
	Playing           bool   `protobuf:"varint,1,opt,name=playing" json:"playing,omitempty"`
	ToggleSampleIndex uint64 `protobuf:"varint,2,opt,name=toggleSampleIndex" json:"toggleSampleIndex,omitempty"`
}

func (*PauseInfo) Descriptor

func (*PauseInfo) Descriptor() ([]byte, []int)

func (*PauseInfo) GetPlaying

func (m *PauseInfo) GetPlaying() bool

func (*PauseInfo) GetToggleSampleIndex

func (m *PauseInfo) GetToggleSampleIndex() uint64

func (*PauseInfo) ProtoMessage

func (*PauseInfo) ProtoMessage()

func (*PauseInfo) Reset

func (m *PauseInfo) Reset()

func (*PauseInfo) String

func (m *PauseInfo) String() string

type PingMessage

type PingMessage struct {
}

func (*PingMessage) Descriptor

func (*PingMessage) Descriptor() ([]byte, []int)

func (*PingMessage) ProtoMessage

func (*PingMessage) ProtoMessage()

func (*PingMessage) Reset

func (m *PingMessage) Reset()

func (*PingMessage) String

func (m *PingMessage) String() string

type PongMessage

type PongMessage struct {
}

func (*PongMessage) Descriptor

func (*PongMessage) Descriptor() ([]byte, []int)

func (*PongMessage) ProtoMessage

func (*PongMessage) ProtoMessage()

func (*PongMessage) Reset

func (m *PongMessage) Reset()

func (*PongMessage) String

func (m *PongMessage) String() string

type QueueChunkRequest

type QueueChunkRequest struct {
	StartTime        int64     `protobuf:"varint,1,opt,name=startTime" json:"startTime,omitempty"`
	ChunkId          int64     `protobuf:"varint,2,opt,name=chunkId" json:"chunkId,omitempty"`
	SampleLow        []float64 `protobuf:"fixed64,3,rep,packed,name=sampleLow" json:"sampleLow,omitempty"`
	SampleHigh       []float64 `protobuf:"fixed64,4,rep,packed,name=sampleHigh" json:"sampleHigh,omitempty"`
	FirstSampleIndex uint64    `protobuf:"varint,5,opt,name=firstSampleIndex" json:"firstSampleIndex,omitempty"`
}

func (*QueueChunkRequest) Descriptor

func (*QueueChunkRequest) Descriptor() ([]byte, []int)

func (*QueueChunkRequest) GetChunkId

func (m *QueueChunkRequest) GetChunkId() int64

func (*QueueChunkRequest) GetFirstSampleIndex

func (m *QueueChunkRequest) GetFirstSampleIndex() uint64

func (*QueueChunkRequest) GetSampleHigh

func (m *QueueChunkRequest) GetSampleHigh() []float64

func (*QueueChunkRequest) GetSampleLow

func (m *QueueChunkRequest) GetSampleLow() []float64

func (*QueueChunkRequest) GetStartTime

func (m *QueueChunkRequest) GetStartTime() int64

func (*QueueChunkRequest) ProtoMessage

func (*QueueChunkRequest) ProtoMessage()

func (*QueueChunkRequest) Reset

func (m *QueueChunkRequest) Reset()

func (*QueueChunkRequest) String

func (m *QueueChunkRequest) String() string

type SetVolumeRequest

type SetVolumeRequest struct {
	Volume float64 `protobuf:"fixed64,1,opt,name=volume" json:"volume,omitempty"`
}

func (*SetVolumeRequest) Descriptor

func (*SetVolumeRequest) Descriptor() ([]byte, []int)

func (*SetVolumeRequest) GetVolume

func (m *SetVolumeRequest) GetVolume() float64

func (*SetVolumeRequest) ProtoMessage

func (*SetVolumeRequest) ProtoMessage()

func (*SetVolumeRequest) Reset

func (m *SetVolumeRequest) Reset()

func (*SetVolumeRequest) String

func (m *SetVolumeRequest) String() string

type SubscribeChannelRequest

type SubscribeChannelRequest struct {
	Channel Channel `protobuf:"varint,1,opt,name=channel,enum=comm.Channel" json:"channel,omitempty"`
}

func (*SubscribeChannelRequest) Descriptor

func (*SubscribeChannelRequest) Descriptor() ([]byte, []int)

func (*SubscribeChannelRequest) GetChannel

func (m *SubscribeChannelRequest) GetChannel() Channel

func (*SubscribeChannelRequest) ProtoMessage

func (*SubscribeChannelRequest) ProtoMessage()

func (*SubscribeChannelRequest) Reset

func (m *SubscribeChannelRequest) Reset()

func (*SubscribeChannelRequest) String

func (m *SubscribeChannelRequest) String() string

type TimeSyncRequest

type TimeSyncRequest struct {
	ClientSend int64 `protobuf:"varint,1,opt,name=clientSend" json:"clientSend,omitempty"`
}

func (*TimeSyncRequest) Descriptor

func (*TimeSyncRequest) Descriptor() ([]byte, []int)

func (*TimeSyncRequest) GetClientSend

func (m *TimeSyncRequest) GetClientSend() int64

func (*TimeSyncRequest) ProtoMessage

func (*TimeSyncRequest) ProtoMessage()

func (*TimeSyncRequest) Reset

func (m *TimeSyncRequest) Reset()

func (*TimeSyncRequest) String

func (m *TimeSyncRequest) String() string

type TimeSyncResponse

type TimeSyncResponse struct {
	ClientSendTime int64 `protobuf:"varint,1,opt,name=clientSendTime" json:"clientSendTime,omitempty"`
	ServerRecvTime int64 `protobuf:"varint,2,opt,name=serverRecvTime" json:"serverRecvTime,omitempty"`
	ServerSendTime int64 `protobuf:"varint,3,opt,name=serverSendTime" json:"serverSendTime,omitempty"`
}

func (*TimeSyncResponse) Descriptor

func (*TimeSyncResponse) Descriptor() ([]byte, []int)

func (*TimeSyncResponse) GetClientSendTime

func (m *TimeSyncResponse) GetClientSendTime() int64

func (*TimeSyncResponse) GetServerRecvTime

func (m *TimeSyncResponse) GetServerRecvTime() int64

func (*TimeSyncResponse) GetServerSendTime

func (m *TimeSyncResponse) GetServerSendTime() int64

func (*TimeSyncResponse) ProtoMessage

func (*TimeSyncResponse) ProtoMessage()

func (*TimeSyncResponse) Reset

func (m *TimeSyncResponse) Reset()

func (*TimeSyncResponse) String

func (m *TimeSyncResponse) String() string

type TypedPackageHandler

type TypedPackageHandler struct {
	TypedPackageHandlerInterface
}

TypedPackageHandler calls the handle functions of TypedPackageHandlerInterface

func (TypedPackageHandler) Handle

func (t TypedPackageHandler) Handle(message proto.Message, sender net.Conn)

Handle forwards the message and sender to the matching Handle function of TypedPackageHandlerInterface

type TypedPackageHandlerInterface

type TypedPackageHandlerInterface interface {
	HandleTimeSyncRequest(*TimeSyncRequest, net.Conn)
	HandleTimeSyncResponse(*TimeSyncResponse, net.Conn)
	HandleQueueChunkRequest(*QueueChunkRequest, net.Conn)
	HandlePingMessage(*PingMessage, net.Conn)
	HandlePongMessage(*PongMessage, net.Conn)
	HandleSetVolumeRequest(*SetVolumeRequest, net.Conn)
	HandleSubscribeChannelRequest(*SubscribeChannelRequest, net.Conn)
	HandleNewSongInfo(*NewSongInfo, net.Conn)
	HandleChunkInfo(*ChunkInfo, net.Conn)
	HandlePauseInfo(*PauseInfo, net.Conn)
}

TypedPackageHandlerInterface has methods to handle all packages received

Jump to

Keyboard shortcuts

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