Archived
2
0
This commit is contained in:
Craig
2020-01-24 15:47:37 +00:00
parent a0866a4ab9
commit e3a73aa264
26 changed files with 1154 additions and 934 deletions

View File

@ -0,0 +1,32 @@
package event
const SYSTEM_DISCONNECT = "system/disconnect"
const SIGNAL_ANSWER = "signal/answer"
const SIGNAL_PROVIDE = "signal/provide"
const IDENTITY_PROVIDE = "identity/provide"
const IDENTITY_DETAILS = "identity/details"
const MEMBER_LIST = "member/list"
const MEMBER_CONNECTED = "member/connected"
const MEMBER_DISCONNECTED = "member/disconnected"
const CONTROL_LOCKED = "control/locked"
const CONTROL_RELEASE = "control/release"
const CONTROL_REQUEST = "control/request"
const CONTROL_REQUESTING = "control/requesting"
const CONTROL_GIVE = "control/give"
const CHAT_MESSAGE = "chat/message"
const CHAT_EMOTE = "chat/emote"
const ADMIN_BAN = "admin/ban"
const ADMIN_KICK = "admin/kick"
const ADMIN_LOCK = "admin/lock"
const ADMIN_MUTE = "admin/mute"
const ADMIN_UNLOCK = "admin/unlock"
const ADMIN_UNMUTE = "admin/unmute"
const ADMIN_CONTROL = "admin/control"
const ADMIN_RELEASE = "admin/release"
const ADMIN_GIVE = "admin/give"

View File

@ -0,0 +1,87 @@
package message
import (
"n.eko.moe/neko/internal/types"
)
type Message struct {
Event string `json:"event"`
}
type Disconnect struct {
Event string `json:"event"`
Message string `json:"message"`
}
type Identity struct {
Event string `json:"event"`
ID string `json:"id"`
}
type IdentityDetails struct {
Event string `json:"event"`
Username string `json:"username"`
}
type Signal struct {
Event string `json:"event"`
SDP string `json:"sdp"`
}
type MembersList struct {
Event string `json:"event"`
Memebers []*types.Member `json:"members"`
}
type Member struct {
Event string `json:"event"`
*types.Member
}
type MemberDisconnected struct {
Event string `json:"event"`
ID string `json:"id"`
}
type Control struct {
Event string `json:"event"`
ID string `json:"id"`
}
type ControlTarget struct {
Event string `json:"event"`
ID string `json:"id"`
Target string `json:"target"`
}
type ChatRecieve struct {
Event string `json:"event"`
Content string `json:"content"`
}
type ChatSend struct {
Event string `json:"event"`
ID string `json:"id"`
Content string `json:"content"`
}
type EmoteRecieve struct {
Event string `json:"event"`
Emote string `json:"emote"`
}
type EmoteSend struct {
Event string `json:"event"`
ID string `json:"id"`
Emote string `json:"emote"`
}
type Admin struct {
Event string `json:"event"`
ID string `json:"id"`
}
type AdminTarget struct {
Event string `json:"event"`
Target string `json:"target"`
ID string `json:"id"`
}

View File

@ -0,0 +1,49 @@
package types
type Member struct {
ID string `json:"id"`
Name string `json:"username"`
Admin bool `json:"admin"`
Muted bool `json:"muted"`
}
type Session interface {
ID() string
Name() string
Admin() bool
Muted() bool
Connected() bool
Member() *Member
SetMuted(muted bool)
SetName(name string) error
SetSocket(socket WebScoket) error
SetPeer(peer Peer) error
Address() *string
Kick(message string) error
Write(v interface{}) error
Send(v interface{}) error
WriteAudioSample(sample Sample) error
WriteVideoSample(sample Sample) error
}
type SessionManager interface {
New(id string, admin bool, socket WebScoket) Session
HasHost() bool
IsHost(id string) bool
SetHost(id string) error
GetHost() (Session, bool)
ClearHost()
Has(id string) bool
Get(id string) (Session, bool)
Members() []*Member
Destroy(id string) error
Clear() error
Brodcast(v interface{}, exclude interface{}) error
WriteAudioSample(sample Sample) error
WriteVideoSample(sample Sample) error
OnHost(listener func(id string))
OnHostCleared(listener func(id string))
OnDestroy(listener func(id string))
OnCreated(listener func(id string, session Session))
OnConnected(listener func(id string, session Session))
}

View File

@ -0,0 +1,19 @@
package types
type Sample struct {
Data []byte
Samples uint32
}
type WebRTCManager interface {
Start()
Shutdown() error
CreatePeer(id string, sdp string) (string, Peer, error)
}
type Peer interface {
WriteVideoSample(sample Sample) error
WriteAudioSample(sample Sample) error
WriteData(v interface{}) error
Destroy() error
}

View File

@ -0,0 +1,7 @@
package types
type WebScoket interface {
Address() *string
Send(v interface{}) error
Destroy() error
}