msg

package
v0.0.0-...-a564318 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2014 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	RAW        byte = 1
	JSON            = 2
	FRAGMENT        = 4
	COMPRESSED      = 8
	DBOP            = 16
	PING            = 32
	RESERVED        = 64
	SETUP           = 128
)

Variables

This section is empty.

Functions

func GetOpFromFetchOpsMsg

func GetOpFromFetchOpsMsg(m *Msg) (string, error)

func IsTrigger

func IsTrigger(msg *Msg) bool

Types

type AddEntry

type AddEntry struct {
	Duration     int64     `json:"duration"`     // the duration of the song
	LastModified int64     `json:"lastmodified"` //
	Guid         string    `json:"guid"`         // the guid of the song
	Annotation   string    `json:"annotation"`   // a annotation ?
	Query        QueryType `json:"query"`        // still not sure
}

type AddFiles

type AddFiles struct {
	Files []File `json:"files"`
	// contains filtered or unexported fields
}

The AddFiles command says that the files listed have been added in this command

func (*AddFiles) GetCommand

func (c *AddFiles) GetCommand() string

func (*AddFiles) GetGuid

func (c *AddFiles) GetGuid() string

type Command

type Command interface {
	GetCommand() string
	GetGuid() string
}

type CommandAllocator

type CommandAllocator func() Command

type CommandParser

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

func NewCommandParser

func NewCommandParser() *CommandParser

func (*CommandParser) ParseCommand

func (c *CommandParser) ParseCommand(m *Msg) (command Command, err error)

func (*CommandParser) Register

func (c *CommandParser) Register(commandName string, allocator CommandAllocator)

type CreatePlaylist

type CreatePlaylist struct {
	Playlist Playlist `json:"playlist"`
	// contains filtered or unexported fields
}

thiscommand says that the given Playlist has been created by this command

func (*CreatePlaylist) GetCommand

func (c *CreatePlaylist) GetCommand() string

func (*CreatePlaylist) GetGuid

func (c *CreatePlaylist) GetGuid() string

type DBsyncOffer

type DBsyncOffer struct {
	Method string `json:"method"` // "dbsync-offer"
	Key    string `json:"key"`    // uuid
}

the message send forgetting dbsync

func ParseDBSyncOffer

func ParseDBSyncOffer(msg *Msg) (*DBsyncOffer, error)

type DeleteFiles

type DeleteFiles struct {
	Ids []int64 `json:"ids"`
	// contains filtered or unexported fields
}

Command saying the the listed ids are of files that have been deleted

func (*DeleteFiles) GetCommand

func (c *DeleteFiles) GetCommand() string

func (*DeleteFiles) GetGuid

func (c *DeleteFiles) GetGuid() string

type DeletePlaylist

type DeletePlaylist struct {
	PlaylistGuid string `json:"playlistguid"`
	// contains filtered or unexported fields
}

Command saying that the playlist wit the given Guid is deleted

func (*DeletePlaylist) GetCommand

func (c *DeletePlaylist) GetCommand() string

func (*DeletePlaylist) GetGuid

func (c *DeletePlaylist) GetGuid() string

type FetchOpsMethod

type FetchOpsMethod interface {
	SendCommand(Command Command) error
	Close() error
}

This is interface represents ONE fetchop workflow

Every call means a given command has been sent. The commands are in order and the interface CAN NOT be used in parallel.

Returning from a method means that the next command can be received. Multiple simultaneous calls to the inteface may cause panic.

None of the commands are guaranteed to be send before Close is called because of the way the protocol is designed. And every last call is never send before Close is called. After Close or after any error returned from any function it should be considered that ALL commands were not send.

When the interface is being implemented in order to receive commands returning error will stop the calling of methods but the network activity may still continue

type File

type File struct {
	Id  int64  `json:"id"`  // the ID of the file
	Url string `json:"url"` // currently only a string representation of the ID
	Song
	Album    string `json:"album"`    // string representation of the Album name
	Mimetype string `json:"mimetype"` // the mime type of the file
	Hash     string `json:"hash"`     // future expanstion
	Year     int    `json:"year"`     // year the song has been release
	Albumpos int    `json:"albumpos"` // position in the album of the song
	Mtime    int64  `json:"mtime"`    // the last modification time of the file in seconds since 1970-01-01
	Duration int    `json:"duration"` // duration of the song in seconds
	Bitrate  int    `json:"bitrate"`  // bitrate of the file (can be 0)
	Size     int    `json:"size"`     // size of the file in bytes
}

A File

type LogPlayback

type LogPlayback struct {
	Song

	Action     int   `json:"action"`     // 1 for start ,2  for stop
	PlayTime   int64 `json:"playtime"`   // time in seconds since 1970-01-01
	SecsPlayed int   `json:"secsPlayed"` // seconds of the song that have been played
	// contains filtered or unexported fields
}

A command saying that a given song has been started or stopped playing action == 1 is start playing, action == 2 is stopped playing the GUID of an Logplayback with action == 1 can not be used in fetchops

func (*LogPlayback) GetCommand

func (c *LogPlayback) GetCommand() string

func (*LogPlayback) GetGuid

func (c *LogPlayback) GetGuid() string

type Msg

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

a generic Message between tomahawks

func MakePingMsg

func MakePingMsg() *Msg

Makes new Ping Message

func NewDBSyncOfferMsg

func NewDBSyncOfferMsg(key string) (m *Msg)

func NewFetchOpsMsg

func NewFetchOpsMsg(op string) *Msg

func NewFileRequestOffer

func NewFileRequestOffer(fileId int64, controlid string) *Msg

Make new Msg that contains a Request for a File with the given id from the given control id

func NewMsg

func NewMsg(payload []byte, flag byte) *Msg

Create new Message with the given payload and flags

func NewSecondaryOffer

func NewSecondaryOffer(controlid, offerId string, port int) *Msg

func ReadMSG

func ReadMSG(reader io.Reader) (msg *Msg, err error)

func WrapCommand

func WrapCommand(c Command, islast bool) *Msg

func (*Msg) Compress

func (t *Msg) Compress()

Compresses an uncompressed payload

func (*Msg) IsCompressed

func (t *Msg) IsCompressed() bool

func (*Msg) IsDBOP

func (t *Msg) IsDBOP() bool

func (*Msg) IsFragment

func (t *Msg) IsFragment() bool

func (*Msg) IsJSON

func (t *Msg) IsJSON() bool

func (*Msg) IsPing

func (t *Msg) IsPing() bool

func (*Msg) IsRaw

func (t *Msg) IsRaw() bool

func (*Msg) IsReserved

func (t *Msg) IsReserved() bool

func (*Msg) IsSetup

func (t *Msg) IsSetup() bool

func (*Msg) Payload

func (t *Msg) Payload() []byte

Returns the payload of the message as byte array

func (*Msg) String

func (t *Msg) String() string

func (*Msg) Uncompress

func (t *Msg) Uncompress()

Uncompresses a compressed payload

func (*Msg) WriteTo

func (m *Msg) WriteTo(w io.Writer) (n int64, err error)

type NotRegisteredError

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

func (NotRegisteredError) Error

func (n NotRegisteredError) Error() string

type OfferMsg

type OfferMsg struct {
	Conntype  string `json:"conntype"`            // : "accept-offer"
	Key       string `json:"key"`                 //  "key" : "whitelist",/ "bb3c6870-ac0f-4822-abad-4439e7ffeb15" / "FILE_REQUEST_KEY:12"
	NodeId    string `json:"nodeid,omitempty"`    //  "nodeid" : "bb3c6870-ac0f-4822-abad-4439e7ffeb15",
	ControlId string `json:"controlid,omitempty"` //  "controlid" : "bb3c6870-ac0f-4822-abad-4439e7ffeb15",
	Port      int    `json:"port"`                //  "port" : 0
}

Generic offer Msg payload

func ParseOffer

func ParseOffer(msg *Msg) (*OfferMsg, error)

parse the payload of the given message as an Offer

type Playlist

type Playlist struct {
	Info            string `json:"info"`            // generic info
	Creator         string `json:"creator"`         // string represeting the creator
	CreatedOn       int64  `json:"createdon"`       // the time it was created as seconds since 1970-01-01
	Title           string `json:"title"`           // the title of the Playlist
	CurrentRevision string `json:"currentrevision"` // revision number
	Shared          bool   `json:"shared"`          // no idea
	Guid            string `json:"guid"`            // UUID of the Playlist
}

A playlist

type QueryType

type QueryType struct {
	Song
	Album    string `json:"album"`    // the album of the song
	Duration int    `json:"duration"` // duration of the song (though it's -1 ) allthe time
	Qid      string `json:"qid"`      // some ID
}

type RenamePlaylist

type RenamePlaylist struct {
	PlaylistGuid  string `json:"playlistguid"`
	PlaylistTitle string `json:"playlistTitle"`
	// contains filtered or unexported fields
}

Rename a playlist

func (*RenamePlaylist) GetCommand

func (c *RenamePlaylist) GetCommand() string

func (*RenamePlaylist) GetGuid

func (c *RenamePlaylist) GetGuid() string

type SetCollectionAttributes

type SetCollectionAttributes struct {
	Del  bool   `json:"del"`
	Id   string `json:"id"`
	Type int    `json:"type"`
	// contains filtered or unexported fields
}

func (*SetCollectionAttributes) GetCommand

func (c *SetCollectionAttributes) GetCommand() string

func (*SetCollectionAttributes) GetGuid

func (c *SetCollectionAttributes) GetGuid() string

type SetPlaylistRevision

type SetPlaylistRevision struct {
	OldRev       string     `json:"oldrev"`       // the old revision of the playlist
	NewRev       string     `json:"newrev"`       // the new revision of the playlist
	PlaylistGuid string     `json:"playlistguid"` // the Guid of the Playlist
	AddEntries   []AddEntry `json:"addedentries"` // the entries to be added
	OrderedGuids []string   `json:"orderedguids"` // the ordered list Of All the songs in the playlist
	// contains filtered or unexported fields
}

Change the playlist

Only new entries are being given in AddEntries the OrderedGuids is the order guids of all the song in the new revision of the playlist. To remove a song you simply skip it in the OrderedGuids

func (*SetPlaylistRevision) GetCommand

func (c *SetPlaylistRevision) GetCommand() string

func (*SetPlaylistRevision) GetGuid

func (c *SetPlaylistRevision) GetGuid() string

type SocialAction

type SocialAction struct {
	Song

	Action string `json:"action"`
	// String representation of the action. "Love" is the only one
	// currently
	Comment string `json:"comment"`
	// comment to the action "true" means Love a song "false" Unlove when
	// Action == Love
	Timestamp int64 `json:"timestamp"` // timestamp of the action
	// contains filtered or unexported fields
}

A social Action command

func (*SocialAction) GetCommand

func (c *SocialAction) GetCommand() string

func (*SocialAction) GetGuid

func (c *SocialAction) GetGuid() string

type Song

type Song struct {
	Artist string `json:"artist"` // Name of the artist
	Track  string `json:"track"`  // Name of the track
}

A song

Jump to

Keyboard shortcuts

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