mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
A huge amount more spelling corrections
This commit is contained in:
parent
addead5005
commit
b31036147d
@ -16,8 +16,8 @@ export type WebSocketMessages =
|
|||||||
| SignalProvideMessage
|
| SignalProvideMessage
|
||||||
| SignalAnswerMessage
|
| SignalAnswerMessage
|
||||||
| MemberListMessage
|
| MemberListMessage
|
||||||
| MembeConnectMessage
|
| MemberConnectMessage
|
||||||
| MembeDisconnectMessage
|
| MemberDisconnectMessage
|
||||||
| ControlMessage
|
| ControlMessage
|
||||||
| ScreenResolutionMessage
|
| ScreenResolutionMessage
|
||||||
| ScreenConfigurationsMessage
|
| ScreenConfigurationsMessage
|
||||||
@ -85,13 +85,13 @@ export interface MemberListPayload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// member/connected
|
// member/connected
|
||||||
export interface MembeConnectMessage extends WebSocketMessage, MemberPayload {
|
export interface MemberConnectMessage extends WebSocketMessage, MemberPayload {
|
||||||
event: typeof EVENT.MEMBER.CONNECTED
|
event: typeof EVENT.MEMBER.CONNECTED
|
||||||
}
|
}
|
||||||
export type MemberPayload = Member
|
export type MemberPayload = Member
|
||||||
|
|
||||||
// member/disconnected
|
// member/disconnected
|
||||||
export interface MembeDisconnectMessage extends WebSocketMessage, MemberPayload {
|
export interface MemberDisconnectMessage extends WebSocketMessage, MemberPayload {
|
||||||
event: typeof EVENT.MEMBER.DISCONNECTED
|
event: typeof EVENT.MEMBER.DISCONNECTED
|
||||||
}
|
}
|
||||||
export interface MemberDisconnectPayload {
|
export interface MemberDisconnectPayload {
|
||||||
|
@ -27,7 +27,7 @@ type SessionManager struct {
|
|||||||
emmiter events.EventEmmiter
|
emmiter events.EventEmmiter
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *SessionManager) New(id string, admin bool, socket types.WebScoket) types.Session {
|
func (manager *SessionManager) New(id string, admin bool, socket types.WebSocket) types.Session {
|
||||||
session := &Session{
|
session := &Session{
|
||||||
id: id,
|
id: id,
|
||||||
admin: admin,
|
admin: admin,
|
||||||
@ -112,7 +112,7 @@ func (manager *SessionManager) Clear() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *SessionManager) Brodcast(v interface{}, exclude interface{}) error {
|
func (manager *SessionManager) Broadcast(v interface{}, exclude interface{}) error {
|
||||||
for id, session := range manager.members {
|
for id, session := range manager.members {
|
||||||
if !session.connected {
|
if !session.connected {
|
||||||
continue
|
continue
|
||||||
|
@ -17,7 +17,7 @@ type Session struct {
|
|||||||
muted bool
|
muted bool
|
||||||
connected bool
|
connected bool
|
||||||
manager *SessionManager
|
manager *SessionManager
|
||||||
socket types.WebScoket
|
socket types.WebSocket
|
||||||
peer types.Peer
|
peer types.Peer
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ func (session *Session) SetName(name string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *Session) SetSocket(socket types.WebScoket) error {
|
func (session *Session) SetSocket(socket types.WebSocket) error {
|
||||||
session.socket = socket
|
session.socket = socket
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -113,11 +113,11 @@ func (session *Session) Write(v interface{}) error {
|
|||||||
return session.socket.Send(v)
|
return session.socket.Send(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *Session) SignalAnwser(sdp string) error {
|
func (session *Session) SignalAnswer(sdp string) error {
|
||||||
if session.peer == nil {
|
if session.peer == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return session.peer.SignalAnwser(sdp)
|
return session.peer.SignalAnswer(sdp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *Session) destroy() error {
|
func (session *Session) destroy() error {
|
||||||
|
@ -32,8 +32,8 @@ func (WebRTC) Init(cmd *cobra.Command) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.PersistentFlags().String("aduio", "", "audio codec parameters to use for streaming (unused)")
|
cmd.PersistentFlags().String("audio", "", "audio codec parameters to use for streaming (unused)")
|
||||||
if err := viper.BindPFlag("aparams", cmd.PersistentFlags().Lookup("aduio")); err != nil {
|
if err := viper.BindPFlag("aparams", cmd.PersistentFlags().Lookup("audio")); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ type ControlTarget struct {
|
|||||||
Target string `json:"target"`
|
Target string `json:"target"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChatRecieve struct {
|
type ChatReceive struct {
|
||||||
Event string `json:"event"`
|
Event string `json:"event"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ type ChatSend struct {
|
|||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type EmoteRecieve struct {
|
type EmoteReceive struct {
|
||||||
Event string `json:"event"`
|
Event string `json:"event"`
|
||||||
Emote string `json:"emote"`
|
Emote string `json:"emote"`
|
||||||
}
|
}
|
||||||
|
@ -17,17 +17,17 @@ type Session interface {
|
|||||||
SetMuted(muted bool)
|
SetMuted(muted bool)
|
||||||
SetName(name string) error
|
SetName(name string) error
|
||||||
SetConnected(connected bool) error
|
SetConnected(connected bool) error
|
||||||
SetSocket(socket WebScoket) error
|
SetSocket(socket WebSocket) error
|
||||||
SetPeer(peer Peer) error
|
SetPeer(peer Peer) error
|
||||||
Address() *string
|
Address() *string
|
||||||
Kick(message string) error
|
Kick(message string) error
|
||||||
Write(v interface{}) error
|
Write(v interface{}) error
|
||||||
Send(v interface{}) error
|
Send(v interface{}) error
|
||||||
SignalAnwser(sdp string) error
|
SignalAnswer(sdp string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type SessionManager interface {
|
type SessionManager interface {
|
||||||
New(id string, admin bool, socket WebScoket) Session
|
New(id string, admin bool, socket WebSocket) Session
|
||||||
HasHost() bool
|
HasHost() bool
|
||||||
IsHost(id string) bool
|
IsHost(id string) bool
|
||||||
SetHost(id string) error
|
SetHost(id string) error
|
||||||
@ -38,7 +38,7 @@ type SessionManager interface {
|
|||||||
Members() []*Member
|
Members() []*Member
|
||||||
Destroy(id string) error
|
Destroy(id string) error
|
||||||
Clear() error
|
Clear() error
|
||||||
Brodcast(v interface{}, exclude interface{}) error
|
Broadcast(v interface{}, exclude interface{}) error
|
||||||
OnHost(listener func(id string))
|
OnHost(listener func(id string))
|
||||||
OnHostCleared(listener func(id string))
|
OnHostCleared(listener func(id string))
|
||||||
OnDestroy(listener func(id string))
|
OnDestroy(listener func(id string))
|
||||||
|
@ -13,7 +13,7 @@ type WebRTCManager interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Peer interface {
|
type Peer interface {
|
||||||
SignalAnwser(sdp string) error
|
SignalAnswer(sdp string) error
|
||||||
WriteData(v interface{}) error
|
WriteData(v interface{}) error
|
||||||
Destroy() error
|
Destroy() error
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package types
|
|||||||
|
|
||||||
import "net/http"
|
import "net/http"
|
||||||
|
|
||||||
type WebScoket interface {
|
type WebSocket interface {
|
||||||
Address() *string
|
Address() *string
|
||||||
Send(v interface{}) error
|
Send(v interface{}) error
|
||||||
Destroy() error
|
Destroy() error
|
||||||
|
@ -13,7 +13,7 @@ type Peer struct {
|
|||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (peer *Peer) SignalAnwser(sdp string) error {
|
func (peer *Peer) SignalAnswer(sdp string) error {
|
||||||
return peer.connection.SetRemoteDescription(webrtc.SessionDescription{SDP: sdp, Type: webrtc.SDPTypeAnswer})
|
return peer.connection.SetRemoteDescription(webrtc.SessionDescription{SDP: sdp, Type: webrtc.SDPTypeAnswer})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,12 +21,12 @@ func (h *MessageHandler) adminLock(id string, session types.Session) error {
|
|||||||
|
|
||||||
h.locked = true
|
h.locked = true
|
||||||
|
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.Admin{
|
message.Admin{
|
||||||
Event: event.ADMIN_LOCK,
|
Event: event.ADMIN_LOCK,
|
||||||
ID: id,
|
ID: id,
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.ADMIN_LOCK)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.ADMIN_LOCK)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,12 +46,12 @@ func (h *MessageHandler) adminUnlock(id string, session types.Session) error {
|
|||||||
|
|
||||||
h.locked = false
|
h.locked = false
|
||||||
|
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.Admin{
|
message.Admin{
|
||||||
Event: event.ADMIN_UNLOCK,
|
Event: event.ADMIN_UNLOCK,
|
||||||
ID: id,
|
ID: id,
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.ADMIN_UNLOCK)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.ADMIN_UNLOCK)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,22 +69,22 @@ func (h *MessageHandler) adminControl(id string, session types.Session) error {
|
|||||||
h.sessions.SetHost(id)
|
h.sessions.SetHost(id)
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.AdminTarget{
|
message.AdminTarget{
|
||||||
Event: event.ADMIN_CONTROL,
|
Event: event.ADMIN_CONTROL,
|
||||||
ID: id,
|
ID: id,
|
||||||
Target: host.ID(),
|
Target: host.ID(),
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.ADMIN_CONTROL)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.ADMIN_CONTROL)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.Admin{
|
message.Admin{
|
||||||
Event: event.ADMIN_CONTROL,
|
Event: event.ADMIN_CONTROL,
|
||||||
ID: id,
|
ID: id,
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.ADMIN_CONTROL)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.ADMIN_CONTROL)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,22 +103,22 @@ func (h *MessageHandler) adminRelease(id string, session types.Session) error {
|
|||||||
h.sessions.ClearHost()
|
h.sessions.ClearHost()
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.AdminTarget{
|
message.AdminTarget{
|
||||||
Event: event.ADMIN_RELEASE,
|
Event: event.ADMIN_RELEASE,
|
||||||
ID: id,
|
ID: id,
|
||||||
Target: host.ID(),
|
Target: host.ID(),
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.ADMIN_RELEASE)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.ADMIN_RELEASE)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.Admin{
|
message.Admin{
|
||||||
Event: event.ADMIN_RELEASE,
|
Event: event.ADMIN_RELEASE,
|
||||||
ID: id,
|
ID: id,
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.ADMIN_RELEASE)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.ADMIN_RELEASE)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,13 +141,13 @@ func (h *MessageHandler) adminGive(id string, session types.Session, payload *me
|
|||||||
h.sessions.SetHost(payload.ID)
|
h.sessions.SetHost(payload.ID)
|
||||||
|
|
||||||
// let everyone know
|
// let everyone know
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.AdminTarget{
|
message.AdminTarget{
|
||||||
Event: event.CONTROL_GIVE,
|
Event: event.CONTROL_GIVE,
|
||||||
ID: id,
|
ID: id,
|
||||||
Target: payload.ID,
|
Target: payload.ID,
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.CONTROL_LOCKED)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.CONTROL_LOCKED)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,13 +173,13 @@ func (h *MessageHandler) adminMute(id string, session types.Session, payload *me
|
|||||||
|
|
||||||
target.SetMuted(true)
|
target.SetMuted(true)
|
||||||
|
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.AdminTarget{
|
message.AdminTarget{
|
||||||
Event: event.ADMIN_MUTE,
|
Event: event.ADMIN_MUTE,
|
||||||
Target: target.ID(),
|
Target: target.ID(),
|
||||||
ID: id,
|
ID: id,
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.ADMIN_UNMUTE)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.ADMIN_UNMUTE)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,13 +200,13 @@ func (h *MessageHandler) adminUnmute(id string, session types.Session, payload *
|
|||||||
|
|
||||||
target.SetMuted(false)
|
target.SetMuted(false)
|
||||||
|
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.AdminTarget{
|
message.AdminTarget{
|
||||||
Event: event.ADMIN_UNMUTE,
|
Event: event.ADMIN_UNMUTE,
|
||||||
Target: target.ID(),
|
Target: target.ID(),
|
||||||
ID: id,
|
ID: id,
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.ADMIN_UNMUTE)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.ADMIN_UNMUTE)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,13 +234,13 @@ func (h *MessageHandler) adminKick(id string, session types.Session, payload *me
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.AdminTarget{
|
message.AdminTarget{
|
||||||
Event: event.ADMIN_KICK,
|
Event: event.ADMIN_KICK,
|
||||||
Target: target.ID(),
|
Target: target.ID(),
|
||||||
ID: id,
|
ID: id,
|
||||||
}, []string{payload.ID}); err != nil {
|
}, []string{payload.ID}); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.ADMIN_KICK)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.ADMIN_KICK)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,13 +284,13 @@ func (h *MessageHandler) adminBan(id string, session types.Session, payload *mes
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.AdminTarget{
|
message.AdminTarget{
|
||||||
Event: event.ADMIN_BAN,
|
Event: event.ADMIN_BAN,
|
||||||
Target: target.ID(),
|
Target: target.ID(),
|
||||||
ID: id,
|
ID: id,
|
||||||
}, []string{payload.ID}); err != nil {
|
}, []string{payload.ID}); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.ADMIN_BAN)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.ADMIN_BAN)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,35 +6,35 @@ import (
|
|||||||
"n.eko.moe/neko/internal/types/message"
|
"n.eko.moe/neko/internal/types/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (h *MessageHandler) chat(id string, session types.Session, payload *message.ChatRecieve) error {
|
func (h *MessageHandler) chat(id string, session types.Session, payload *message.ChatReceive) error {
|
||||||
if session.Muted() {
|
if session.Muted() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.ChatSend{
|
message.ChatSend{
|
||||||
Event: event.CHAT_MESSAGE,
|
Event: event.CHAT_MESSAGE,
|
||||||
Content: payload.Content,
|
Content: payload.Content,
|
||||||
ID: id,
|
ID: id,
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.CONTROL_RELEASE)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.CONTROL_RELEASE)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MessageHandler) chatEmote(id string, session types.Session, payload *message.EmoteRecieve) error {
|
func (h *MessageHandler) chatEmote(id string, session types.Session, payload *message.EmoteReceive) error {
|
||||||
if session.Muted() {
|
if session.Muted() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.EmoteSend{
|
message.EmoteSend{
|
||||||
Event: event.CHAT_EMOTE,
|
Event: event.CHAT_EMOTE,
|
||||||
Emote: payload.Emote,
|
Emote: payload.Emote,
|
||||||
ID: id,
|
ID: id,
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.CONTROL_RELEASE)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.CONTROL_RELEASE)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -20,12 +20,12 @@ func (h *MessageHandler) controlRelease(id string, session types.Session) error
|
|||||||
h.sessions.ClearHost()
|
h.sessions.ClearHost()
|
||||||
|
|
||||||
// tell everyone
|
// tell everyone
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.Control{
|
message.Control{
|
||||||
Event: event.CONTROL_RELEASE,
|
Event: event.CONTROL_RELEASE,
|
||||||
ID: id,
|
ID: id,
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.CONTROL_RELEASE)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.CONTROL_RELEASE)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,12 +39,12 @@ func (h *MessageHandler) controlRequest(id string, session types.Session) error
|
|||||||
h.sessions.SetHost(id)
|
h.sessions.SetHost(id)
|
||||||
|
|
||||||
// let everyone know
|
// let everyone know
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.Control{
|
message.Control{
|
||||||
Event: event.CONTROL_LOCKED,
|
Event: event.CONTROL_LOCKED,
|
||||||
ID: id,
|
ID: id,
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.CONTROL_LOCKED)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.CONTROL_LOCKED)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,13 +93,13 @@ func (h *MessageHandler) controlGive(id string, session types.Session, payload *
|
|||||||
h.sessions.SetHost(payload.ID)
|
h.sessions.SetHost(payload.ID)
|
||||||
|
|
||||||
// let everyone know
|
// let everyone know
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.ControlTarget{
|
message.ControlTarget{
|
||||||
Event: event.CONTROL_GIVE,
|
Event: event.CONTROL_GIVE,
|
||||||
ID: id,
|
ID: id,
|
||||||
Target: payload.ID,
|
Target: payload.ID,
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.CONTROL_LOCKED)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.CONTROL_LOCKED)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,13 +84,13 @@ func (h *MessageHandler) Message(id string, raw []byte) error {
|
|||||||
|
|
||||||
// Chat Events
|
// Chat Events
|
||||||
case event.CHAT_MESSAGE:
|
case event.CHAT_MESSAGE:
|
||||||
payload := &message.ChatRecieve{}
|
payload := &message.ChatReceive{}
|
||||||
return errors.Wrapf(
|
return errors.Wrapf(
|
||||||
utils.Unmarshal(payload, raw, func() error {
|
utils.Unmarshal(payload, raw, func() error {
|
||||||
return h.chat(id, session, payload)
|
return h.chat(id, session, payload)
|
||||||
}), "%s failed", header.Event)
|
}), "%s failed", header.Event)
|
||||||
case event.CHAT_EMOTE:
|
case event.CHAT_EMOTE:
|
||||||
payload := &message.EmoteRecieve{}
|
payload := &message.EmoteReceive{}
|
||||||
return errors.Wrapf(
|
return errors.Wrapf(
|
||||||
utils.Unmarshal(payload, raw, func() error {
|
utils.Unmarshal(payload, raw, func() error {
|
||||||
return h.chatEmote(id, session, payload)
|
return h.chatEmote(id, session, payload)
|
||||||
|
@ -18,7 +18,7 @@ func (h *MessageHandler) screenSet(id string, session types.Session, payload *me
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.ScreenResolution{
|
message.ScreenResolution{
|
||||||
Event: event.SCREEN_RESOLUTION,
|
Event: event.SCREEN_RESOLUTION,
|
||||||
ID: id,
|
ID: id,
|
||||||
@ -26,7 +26,7 @@ func (h *MessageHandler) screenSet(id string, session types.Session, payload *me
|
|||||||
Height: payload.Height,
|
Height: payload.Height,
|
||||||
Rate: payload.Rate,
|
Rate: payload.Rate,
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.SCREEN_RESOLUTION)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.SCREEN_RESOLUTION)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,12 +50,12 @@ func (h *MessageHandler) SessionConnected(id string, session types.Session) erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
// let everyone know there is a new session
|
// let everyone know there is a new session
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.Member{
|
message.Member{
|
||||||
Event: event.MEMBER_CONNECTED,
|
Event: event.MEMBER_CONNECTED,
|
||||||
Member: session.Member(),
|
Member: session.Member(),
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.CONTROL_RELEASE)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.CONTROL_RELEASE)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,21 +66,21 @@ func (h *MessageHandler) SessionDestroyed(id string) error {
|
|||||||
// clear host if exists
|
// clear host if exists
|
||||||
if h.sessions.IsHost(id) {
|
if h.sessions.IsHost(id) {
|
||||||
h.sessions.ClearHost()
|
h.sessions.ClearHost()
|
||||||
if err := h.sessions.Brodcast(message.Control{
|
if err := h.sessions.Broadcast(message.Control{
|
||||||
Event: event.CONTROL_RELEASE,
|
Event: event.CONTROL_RELEASE,
|
||||||
ID: id,
|
ID: id,
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.CONTROL_RELEASE)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.CONTROL_RELEASE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// let everyone know session disconnected
|
// let everyone know session disconnected
|
||||||
if err := h.sessions.Brodcast(
|
if err := h.sessions.Broadcast(
|
||||||
message.MemberDisconnected{
|
message.MemberDisconnected{
|
||||||
Event: event.MEMBER_DISCONNECTED,
|
Event: event.MEMBER_DISCONNECTED,
|
||||||
ID: id,
|
ID: id,
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
h.logger.Warn().Err(err).Msgf("brodcasting event %s has failed", event.MEMBER_DISCONNECTED)
|
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.MEMBER_DISCONNECTED)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ func (h *MessageHandler) signalAnswer(id string, session types.Session, payload
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := session.SignalAnwser(payload.SDP); err != nil {
|
if err := session.SignalAnswer(payload.SDP); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ func (ws *WebSocketHandler) Upgrade(w http.ResponseWriter, r *http.Request) erro
|
|||||||
|
|
||||||
id, admin, err := ws.authenticate(r)
|
id, admin, err := ws.authenticate(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ws.logger.Warn().Err(err).Msg("authenticatetion failed")
|
ws.logger.Warn().Err(err).Msg("authentication failed")
|
||||||
|
|
||||||
if err = connection.WriteJSON(message.Disconnect{
|
if err = connection.WriteJSON(message.Disconnect{
|
||||||
Event: event.SYSTEM_DISCONNECT,
|
Event: event.SYSTEM_DISCONNECT,
|
||||||
@ -243,7 +243,7 @@ func (ws *WebSocketHandler) handle(connection *websocket.Conn, id string) {
|
|||||||
Str("session", id).
|
Str("session", id).
|
||||||
Str("address", connection.RemoteAddr().String()).
|
Str("address", connection.RemoteAddr().String()).
|
||||||
Str("raw", string(raw)).
|
Str("raw", string(raw)).
|
||||||
Msg("recieved message from client")
|
Msg("received message from client")
|
||||||
if err := ws.handler.Message(id, raw); err != nil {
|
if err := ws.handler.Message(id, raw); err != nil {
|
||||||
ws.logger.Error().Err(err).Msg("message handler has failed")
|
ws.logger.Error().Err(err).Msg("message handler has failed")
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ func (i *Version) String() string {
|
|||||||
func (i *Version) Details() string {
|
func (i *Version) Details() string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
|
"%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
|
||||||
fmt.Sprintf("Verison %s.%s.%s", i.Major, i.Minor, i.Patch),
|
fmt.Sprintf("Version %s.%s.%s", i.Major, i.Minor, i.Patch),
|
||||||
fmt.Sprintf("GitCommit %s", i.GitCommit),
|
fmt.Sprintf("GitCommit %s", i.GitCommit),
|
||||||
fmt.Sprintf("GitBranch %s", i.GitBranch),
|
fmt.Sprintf("GitBranch %s", i.GitBranch),
|
||||||
fmt.Sprintf("BuildDate %s", i.BuildDate),
|
fmt.Sprintf("BuildDate %s", i.BuildDate),
|
||||||
|
Loading…
Reference in New Issue
Block a user