mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
progress on server refactor
This commit is contained in:
@ -11,12 +11,21 @@ type Session struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"username"`
|
||||
Admin bool `json:"admin"`
|
||||
Muted bool `json:"-"`
|
||||
connected bool
|
||||
socket *websocket.Conn
|
||||
peer *webrtc.PeerConnection
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (session *Session) RemoteAddr() *string {
|
||||
if session.socket != nil {
|
||||
address := session.socket.RemoteAddr().String()
|
||||
return &address
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO: write to peer data channel
|
||||
func (session *Session) Write(v interface{}) error {
|
||||
session.mu.Lock()
|
||||
@ -24,6 +33,14 @@ func (session *Session) Write(v interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (session *Session) Kick(v interface{}) error {
|
||||
if err := session.Send(v); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return session.destroy()
|
||||
}
|
||||
|
||||
func (session *Session) Send(v interface{}) error {
|
||||
session.mu.Lock()
|
||||
defer session.mu.Unlock()
|
||||
|
Reference in New Issue
Block a user