Merge pull request #40 from GigaFyde/master

A lot more spelling corrections
This commit is contained in:
Nurdism 2020-02-27 02:05:37 -05:00 committed by GitHub
commit 78bf6fbe4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 76 additions and 76 deletions

View File

@ -52,7 +52,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
}
if (username === '') {
throw new Error('Must add a username') // TODO: Better handleing
throw new Error('Must add a username') // TODO: Better handling
}
this._username = username
@ -98,7 +98,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
public sendData(event: 'mousedown' | 'mouseup' | 'keydown' | 'keyup', data: { key: number }): void
public sendData(event: string, data: any) {
if (!this.connected) {
this.emit('warn', `attemping to send data while dissconneted`)
this.emit('warn', `attempting to send data while disconnected`)
return
}
@ -149,7 +149,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
public sendMessage(event: WebSocketEvents, payload?: WebSocketPayloads) {
if (!this.connected) {
this.emit('warn', `attemping to send message while dissconneted`)
this.emit('warn', `attempting to send message while disconnected`)
return
}
this.emit('debug', `sending event '${event}' ${payload ? `with payload: ` : ''}`, payload)
@ -175,17 +175,17 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
this._peer = new RTCPeerConnection()
this._peer.onconnectionstatechange = event => {
this.emit('debug', `peer connection state chagned`, this._peer ? this._peer.connectionState : undefined)
this.emit('debug', `peer connection state changed`, this._peer ? this._peer.connectionState : undefined)
}
this._peer.onsignalingstatechange = event => {
this.emit('debug', `peer signaling state chagned`, this._peer ? this._peer.signalingState : undefined)
this.emit('debug', `peer signaling state changed`, this._peer ? this._peer.signalingState : undefined)
}
this._peer.oniceconnectionstatechange = event => {
this._state = this._peer!.iceConnectionState
this.emit('debug', `peer ice connection state chagned: ${this._peer!.iceConnectionState}`)
this.emit('debug', `peer ice connection state changed: ${this._peer!.iceConnectionState}`)
switch (this._state) {
case 'checking':
@ -284,7 +284,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
}
private onTimeout() {
this.emit('debug', `connection timedout`)
this.emit('debug', `connection timeout`)
if (this._timeout) {
clearTimeout(this._timeout)
}

View File

@ -16,8 +16,8 @@ export type WebSocketMessages =
| SignalProvideMessage
| SignalAnswerMessage
| MemberListMessage
| MembeConnectMessage
| MembeDisconnectMessage
| MemberConnectMessage
| MemberDisconnectMessage
| ControlMessage
| ScreenResolutionMessage
| ScreenConfigurationsMessage
@ -85,13 +85,13 @@ export interface MemberListPayload {
}
// member/connected
export interface MembeConnectMessage extends WebSocketMessage, MemberPayload {
export interface MemberConnectMessage extends WebSocketMessage, MemberPayload {
event: typeof EVENT.MEMBER.CONNECTED
}
export type MemberPayload = Member
// member/disconnected
export interface MembeDisconnectMessage extends WebSocketMessage, MemberPayload {
export interface MemberDisconnectMessage extends WebSocketMessage, MemberPayload {
event: typeof EVENT.MEMBER.DISCONNECTED
}
export interface MemberDisconnectPayload {

View File

@ -27,7 +27,7 @@ type SessionManager struct {
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{
id: id,
admin: admin,
@ -112,7 +112,7 @@ func (manager *SessionManager) Clear() error {
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 {
if !session.connected {
continue

View File

@ -17,7 +17,7 @@ type Session struct {
muted bool
connected bool
manager *SessionManager
socket types.WebScoket
socket types.WebSocket
peer types.Peer
mu sync.Mutex
}
@ -67,7 +67,7 @@ func (session *Session) SetName(name string) error {
return nil
}
func (session *Session) SetSocket(socket types.WebScoket) error {
func (session *Session) SetSocket(socket types.WebSocket) error {
session.socket = socket
return nil
}
@ -113,11 +113,11 @@ func (session *Session) Write(v interface{}) error {
return session.socket.Send(v)
}
func (session *Session) SignalAnwser(sdp string) error {
func (session *Session) SignalAnswer(sdp string) error {
if session.peer == nil {
return nil
}
return session.peer.SignalAnwser(sdp)
return session.peer.SignalAnswer(sdp)
}
func (session *Session) destroy() error {

View File

@ -32,8 +32,8 @@ func (WebRTC) Init(cmd *cobra.Command) error {
return err
}
cmd.PersistentFlags().String("aduio", "", "audio codec parameters to use for streaming (unused)")
if err := viper.BindPFlag("aparams", cmd.PersistentFlags().Lookup("aduio")); err != nil {
cmd.PersistentFlags().String("audio", "", "audio codec parameters to use for streaming (unused)")
if err := viper.BindPFlag("aparams", cmd.PersistentFlags().Lookup("audio")); err != nil {
return err
}

View File

@ -55,7 +55,7 @@ type ControlTarget struct {
Target string `json:"target"`
}
type ChatRecieve struct {
type ChatReceive struct {
Event string `json:"event"`
Content string `json:"content"`
}
@ -66,7 +66,7 @@ type ChatSend struct {
Content string `json:"content"`
}
type EmoteRecieve struct {
type EmoteReceive struct {
Event string `json:"event"`
Emote string `json:"emote"`
}

View File

@ -17,17 +17,17 @@ type Session interface {
SetMuted(muted bool)
SetName(name string) error
SetConnected(connected bool) error
SetSocket(socket WebScoket) error
SetSocket(socket WebSocket) error
SetPeer(peer Peer) error
Address() *string
Kick(message string) error
Write(v interface{}) error
Send(v interface{}) error
SignalAnwser(sdp string) error
SignalAnswer(sdp string) error
}
type SessionManager interface {
New(id string, admin bool, socket WebScoket) Session
New(id string, admin bool, socket WebSocket) Session
HasHost() bool
IsHost(id string) bool
SetHost(id string) error
@ -38,7 +38,7 @@ type SessionManager interface {
Members() []*Member
Destroy(id string) error
Clear() error
Brodcast(v interface{}, exclude interface{}) error
Broadcast(v interface{}, exclude interface{}) error
OnHost(listener func(id string))
OnHostCleared(listener func(id string))
OnDestroy(listener func(id string))

View File

@ -13,7 +13,7 @@ type WebRTCManager interface {
}
type Peer interface {
SignalAnwser(sdp string) error
SignalAnswer(sdp string) error
WriteData(v interface{}) error
Destroy() error
}

View File

@ -2,7 +2,7 @@ package types
import "net/http"
type WebScoket interface {
type WebSocket interface {
Address() *string
Send(v interface{}) error
Destroy() error

View File

@ -13,7 +13,7 @@ type Peer struct {
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})
}

View File

@ -21,12 +21,12 @@ func (h *MessageHandler) adminLock(id string, session types.Session) error {
h.locked = true
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.Admin{
Event: event.ADMIN_LOCK,
ID: id,
}, 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
}
@ -46,12 +46,12 @@ func (h *MessageHandler) adminUnlock(id string, session types.Session) error {
h.locked = false
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.Admin{
Event: event.ADMIN_UNLOCK,
ID: id,
}, 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
}
@ -69,22 +69,22 @@ func (h *MessageHandler) adminControl(id string, session types.Session) error {
h.sessions.SetHost(id)
if ok {
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.AdminTarget{
Event: event.ADMIN_CONTROL,
ID: id,
Target: host.ID(),
}, 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
}
} else {
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.Admin{
Event: event.ADMIN_CONTROL,
ID: id,
}, 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
}
}
@ -103,22 +103,22 @@ func (h *MessageHandler) adminRelease(id string, session types.Session) error {
h.sessions.ClearHost()
if ok {
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.AdminTarget{
Event: event.ADMIN_RELEASE,
ID: id,
Target: host.ID(),
}, 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
}
} else {
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.Admin{
Event: event.ADMIN_RELEASE,
ID: id,
}, 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
}
}
@ -141,13 +141,13 @@ func (h *MessageHandler) adminGive(id string, session types.Session, payload *me
h.sessions.SetHost(payload.ID)
// let everyone know
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.AdminTarget{
Event: event.CONTROL_GIVE,
ID: id,
Target: payload.ID,
}, 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
}
@ -173,13 +173,13 @@ func (h *MessageHandler) adminMute(id string, session types.Session, payload *me
target.SetMuted(true)
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.AdminTarget{
Event: event.ADMIN_MUTE,
Target: target.ID(),
ID: id,
}, 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
}
@ -200,13 +200,13 @@ func (h *MessageHandler) adminUnmute(id string, session types.Session, payload *
target.SetMuted(false)
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.AdminTarget{
Event: event.ADMIN_UNMUTE,
Target: target.ID(),
ID: id,
}, 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
}
@ -234,13 +234,13 @@ func (h *MessageHandler) adminKick(id string, session types.Session, payload *me
return err
}
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.AdminTarget{
Event: event.ADMIN_KICK,
Target: target.ID(),
ID: id,
}, []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
}
@ -284,13 +284,13 @@ func (h *MessageHandler) adminBan(id string, session types.Session, payload *mes
return err
}
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.AdminTarget{
Event: event.ADMIN_BAN,
Target: target.ID(),
ID: id,
}, []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
}

View File

@ -6,35 +6,35 @@ import (
"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() {
return nil
}
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.ChatSend{
Event: event.CHAT_MESSAGE,
Content: payload.Content,
ID: id,
}, 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 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() {
return nil
}
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.EmoteSend{
Event: event.CHAT_EMOTE,
Emote: payload.Emote,
ID: id,
}, 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 nil

View File

@ -20,12 +20,12 @@ func (h *MessageHandler) controlRelease(id string, session types.Session) error
h.sessions.ClearHost()
// tell everyone
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.Control{
Event: event.CONTROL_RELEASE,
ID: id,
}, 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
}
@ -39,12 +39,12 @@ func (h *MessageHandler) controlRequest(id string, session types.Session) error
h.sessions.SetHost(id)
// let everyone know
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.Control{
Event: event.CONTROL_LOCKED,
ID: id,
}, 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
}
@ -93,13 +93,13 @@ func (h *MessageHandler) controlGive(id string, session types.Session, payload *
h.sessions.SetHost(payload.ID)
// let everyone know
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.ControlTarget{
Event: event.CONTROL_GIVE,
ID: id,
Target: payload.ID,
}, 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
}

View File

@ -84,13 +84,13 @@ func (h *MessageHandler) Message(id string, raw []byte) error {
// Chat Events
case event.CHAT_MESSAGE:
payload := &message.ChatRecieve{}
payload := &message.ChatReceive{}
return errors.Wrapf(
utils.Unmarshal(payload, raw, func() error {
return h.chat(id, session, payload)
}), "%s failed", header.Event)
case event.CHAT_EMOTE:
payload := &message.EmoteRecieve{}
payload := &message.EmoteReceive{}
return errors.Wrapf(
utils.Unmarshal(payload, raw, func() error {
return h.chatEmote(id, session, payload)

View File

@ -18,7 +18,7 @@ func (h *MessageHandler) screenSet(id string, session types.Session, payload *me
return err
}
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.ScreenResolution{
Event: event.SCREEN_RESOLUTION,
ID: id,
@ -26,7 +26,7 @@ func (h *MessageHandler) screenSet(id string, session types.Session, payload *me
Height: payload.Height,
Rate: payload.Rate,
}, 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
}

View File

@ -50,12 +50,12 @@ func (h *MessageHandler) SessionConnected(id string, session types.Session) erro
}
// let everyone know there is a new session
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.Member{
Event: event.MEMBER_CONNECTED,
Member: session.Member(),
}, 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
}
@ -66,21 +66,21 @@ func (h *MessageHandler) SessionDestroyed(id string) error {
// clear host if exists
if h.sessions.IsHost(id) {
h.sessions.ClearHost()
if err := h.sessions.Brodcast(message.Control{
if err := h.sessions.Broadcast(message.Control{
Event: event.CONTROL_RELEASE,
ID: id,
}, 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
if err := h.sessions.Brodcast(
if err := h.sessions.Broadcast(
message.MemberDisconnected{
Event: event.MEMBER_DISCONNECTED,
ID: id,
}, 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
}

View File

@ -28,7 +28,7 @@ func (h *MessageHandler) signalAnswer(id string, session types.Session, payload
return err
}
if err := session.SignalAnwser(payload.SDP); err != nil {
if err := session.SignalAnswer(payload.SDP); err != nil {
return err
}

View File

@ -125,7 +125,7 @@ func (ws *WebSocketHandler) Upgrade(w http.ResponseWriter, r *http.Request) erro
id, admin, err := ws.authenticate(r)
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{
Event: event.SYSTEM_DISCONNECT,
@ -243,7 +243,7 @@ func (ws *WebSocketHandler) handle(connection *websocket.Conn, id string) {
Str("session", id).
Str("address", connection.RemoteAddr().String()).
Str("raw", string(raw)).
Msg("recieved message from client")
Msg("received message from client")
if err := ws.handler.Message(id, raw); err != nil {
ws.logger.Error().Err(err).Msg("message handler has failed")
}

View File

@ -83,7 +83,7 @@ func (i *Version) String() string {
func (i *Version) Details() string {
return fmt.Sprintf(
"%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("GitBranch %s", i.GitBranch),
fmt.Sprintf("BuildDate %s", i.BuildDate),