mirror of
https://github.com/m1k1o/neko.git
synced 2025-05-14 17:47:46 +02:00
progress on server refactor
This commit is contained in:
parent
78af798d68
commit
d497806443
13 changed files with 436 additions and 51 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue