27 changed files with 1146 additions and 176 deletions
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
/* |
||||
* Spreed WebRTC. |
||||
* Copyright (C) 2013-2015 struktur AG |
||||
* |
||||
* This file is part of Spreed WebRTC. |
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU Affero General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* |
||||
*/ |
||||
|
||||
package channelling |
||||
|
||||
type SessionCreateRequest struct { |
||||
Id string |
||||
Session *DataSession |
||||
Room *DataRoom |
||||
SetAsDefault bool |
||||
} |
||||
|
||||
type DataSink struct { |
||||
SubjectOut string `json:subject_out"` |
||||
SubjectIn string `json:subject_in"` |
||||
} |
||||
|
||||
type DataSinkOutgoing struct { |
||||
Outgoing *DataOutgoing |
||||
ToUserid string |
||||
FromUserid string |
||||
Pipe string `json:",omitempty"` |
||||
} |
@ -0,0 +1,266 @@
@@ -0,0 +1,266 @@
|
||||
/* |
||||
* Spreed WebRTC. |
||||
* Copyright (C) 2013-2015 struktur AG |
||||
* |
||||
* This file is part of Spreed WebRTC. |
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU Affero General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* |
||||
*/ |
||||
|
||||
package channelling |
||||
|
||||
import ( |
||||
"bytes" |
||||
"encoding/json" |
||||
"errors" |
||||
"log" |
||||
"sync" |
||||
"time" |
||||
|
||||
"github.com/strukturag/spreed-webrtc/go/buffercache" |
||||
) |
||||
|
||||
type PipelineFeedLine struct { |
||||
Seq int |
||||
Msg *DataOutgoing |
||||
} |
||||
|
||||
type Pipeline struct { |
||||
PipelineManager PipelineManager |
||||
mutex sync.RWMutex |
||||
namespace string |
||||
id string |
||||
from *Session |
||||
to *Session |
||||
expires *time.Time |
||||
data []*DataSinkOutgoing |
||||
sink Sink |
||||
recvQueue chan *DataIncoming |
||||
closed bool |
||||
} |
||||
|
||||
func NewPipeline(manager PipelineManager, |
||||
namespace string, |
||||
id string, |
||||
from *Session, |
||||
duration time.Duration) *Pipeline { |
||||
pipeline := &Pipeline{ |
||||
PipelineManager: manager, |
||||
namespace: namespace, |
||||
id: id, |
||||
from: from, |
||||
recvQueue: make(chan *DataIncoming, 100), |
||||
} |
||||
go pipeline.receive() |
||||
pipeline.Refresh(duration) |
||||
return pipeline |
||||
} |
||||
|
||||
func (pipeline *Pipeline) receive() { |
||||
// TODO(longsleep): Call to ToSession() should be avoided because it locks.
|
||||
api := pipeline.PipelineManager.GetChannellingAPI() |
||||
for data := range pipeline.recvQueue { |
||||
_, err := api.OnIncoming(nil, pipeline.ToSession(), data) |
||||
if err != nil { |
||||
// TODO(longsleep): Handle reply and error.
|
||||
log.Println("Pipeline receive incoming error", err) |
||||
} |
||||
} |
||||
log.Println("Pipeline receive done") |
||||
} |
||||
|
||||
func (pipeline *Pipeline) GetID() string { |
||||
return pipeline.id |
||||
} |
||||
|
||||
func (pipeline *Pipeline) Refresh(duration time.Duration) { |
||||
pipeline.mutex.Lock() |
||||
pipeline.refresh(duration) |
||||
pipeline.mutex.Unlock() |
||||
} |
||||
|
||||
func (pipeline *Pipeline) refresh(duration time.Duration) { |
||||
expiration := time.Now().Add(duration) |
||||
pipeline.expires = &expiration |
||||
} |
||||
|
||||
func (pipeline *Pipeline) Add(msg *DataSinkOutgoing) *Pipeline { |
||||
msg.Pipe = pipeline.id |
||||
pipeline.mutex.Lock() |
||||
pipeline.data = append(pipeline.data, msg) |
||||
pipeline.refresh(30 * time.Second) |
||||
pipeline.mutex.Unlock() |
||||
|
||||
return pipeline |
||||
} |
||||
|
||||
func (pipeline *Pipeline) Send(b buffercache.Buffer) { |
||||
// Noop.
|
||||
} |
||||
|
||||
func (pipeline *Pipeline) Index() uint64 { |
||||
return 0 |
||||
} |
||||
|
||||
func (pipeline *Pipeline) Close() { |
||||
pipeline.mutex.Lock() |
||||
if !pipeline.closed { |
||||
pipeline.expires = nil |
||||
if pipeline.sink != nil { |
||||
pipeline.sink = nil |
||||
} |
||||
close(pipeline.recvQueue) |
||||
pipeline.closed = true |
||||
log.Println("Closed pipeline") |
||||
} |
||||
pipeline.mutex.Unlock() |
||||
} |
||||
|
||||
func (pipeline *Pipeline) Expired() bool { |
||||
var expired bool |
||||
pipeline.mutex.RLock() |
||||
if pipeline.expires == nil { |
||||
expired = true |
||||
} else { |
||||
expired = pipeline.expires.Before(time.Now()) |
||||
} |
||||
pipeline.mutex.RUnlock() |
||||
|
||||
return expired |
||||
} |
||||
|
||||
func (pipeline *Pipeline) FromSession() *Session { |
||||
pipeline.mutex.RLock() |
||||
defer pipeline.mutex.RUnlock() |
||||
return pipeline.from |
||||
} |
||||
|
||||
func (pipeline *Pipeline) ToSession() *Session { |
||||
pipeline.mutex.RLock() |
||||
defer pipeline.mutex.RUnlock() |
||||
return pipeline.to |
||||
} |
||||
|
||||
func (pipeline *Pipeline) JSONFeed(since, limit int) ([]byte, error) { |
||||
pipeline.mutex.RLock() |
||||
var lineRaw []byte |
||||
var line *PipelineFeedLine |
||||
var buffer bytes.Buffer |
||||
var err error |
||||
data := pipeline.data[since:] |
||||
count := 0 |
||||
for seq, msg := range data { |
||||
line = &PipelineFeedLine{ |
||||
Seq: seq + since, |
||||
Msg: msg.Outgoing, |
||||
} |
||||
lineRaw, err = json.Marshal(line) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
buffer.Write(lineRaw) |
||||
buffer.WriteString("\n") |
||||
|
||||
count++ |
||||
if limit > 0 && count >= limit { |
||||
break |
||||
} |
||||
} |
||||
pipeline.mutex.RUnlock() |
||||
|
||||
return buffer.Bytes(), nil |
||||
} |
||||
|
||||
func (pipeline *Pipeline) FlushOutgoing(hub Hub, client *Client, to string, outgoing *DataOutgoing) bool { |
||||
//log.Println("Flush outgoing via pipeline", to, client == nil)
|
||||
if client == nil { |
||||
sinkOutgoing := &DataSinkOutgoing{ |
||||
Outgoing: outgoing, |
||||
} |
||||
|
||||
pipeline.mutex.Lock() |
||||
sink := pipeline.sink |
||||
toSession := pipeline.to |
||||
fromSession := pipeline.from |
||||
|
||||
for { |
||||
if sink != nil && sink.Enabled() { |
||||
// Sink it.
|
||||
pipeline.mutex.Unlock() |
||||
break |
||||
} |
||||
|
||||
sink, toSession = pipeline.PipelineManager.FindSinkAndSession(to) |
||||
if sink != nil { |
||||
pipeline.to = toSession |
||||
err := pipeline.attach(sink) |
||||
if err == nil { |
||||
pipeline.mutex.Unlock() |
||||
|
||||
// Create incoming receiver.
|
||||
sink.BindRecvChan(pipeline.recvQueue) |
||||
|
||||
// Sink it.
|
||||
break |
||||
} |
||||
} |
||||
|
||||
// Not pipelined, do nothing.
|
||||
pipeline.mutex.Unlock() |
||||
break |
||||
} |
||||
|
||||
if fromSession != nil { |
||||
sinkOutgoing.FromUserid = fromSession.Userid() |
||||
} |
||||
if toSession != nil { |
||||
sinkOutgoing.ToUserid = toSession.Userid() |
||||
} |
||||
pipeline.Add(sinkOutgoing) |
||||
|
||||
if sink != nil { |
||||
// Pipelined, sink data.
|
||||
sink.Write(sinkOutgoing) |
||||
return true |
||||
} |
||||
} |
||||
|
||||
return false |
||||
} |
||||
|
||||
func (pipeline *Pipeline) Attach(sink Sink) error { |
||||
pipeline.mutex.Lock() |
||||
defer pipeline.mutex.Unlock() |
||||
|
||||
// Sink existing data first.
|
||||
log.Println("Attach sink to pipeline", pipeline.id) |
||||
err := pipeline.attach(sink) |
||||
if err == nil { |
||||
for _, msg := range pipeline.data { |
||||
log.Println("Flushing pipeline to sink after attach", len(pipeline.data)) |
||||
sink.Write(msg) |
||||
} |
||||
} |
||||
|
||||
return err |
||||
} |
||||
|
||||
func (pipeline *Pipeline) attach(sink Sink) error { |
||||
if pipeline.sink != nil { |
||||
return errors.New("pipeline already attached to sink") |
||||
} |
||||
pipeline.sink = sink |
||||
return nil |
||||
} |
@ -0,0 +1,234 @@
@@ -0,0 +1,234 @@
|
||||
/* |
||||
* Spreed WebRTC. |
||||
* Copyright (C) 2013-2015 struktur AG |
||||
* |
||||
* This file is part of Spreed WebRTC. |
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU Affero General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* |
||||
*/ |
||||
|
||||
package channelling |
||||
|
||||
import ( |
||||
"fmt" |
||||
"log" |
||||
"sync" |
||||
"time" |
||||
) |
||||
|
||||
const ( |
||||
PipelineNamespaceCall = "call" |
||||
) |
||||
|
||||
type PipelineManager interface { |
||||
BusManager |
||||
SessionStore |
||||
UserStore |
||||
SessionCreator |
||||
GetPipelineByID(id string) (pipeline *Pipeline, ok bool) |
||||
GetPipeline(namespace string, sender Sender, session *Session, to string) *Pipeline |
||||
FindSinkAndSession(to string) (Sink, *Session) |
||||
} |
||||
|
||||
type pipelineManager struct { |
||||
BusManager |
||||
SessionStore |
||||
UserStore |
||||
SessionCreator |
||||
mutex sync.RWMutex |
||||
pipelineTable map[string]*Pipeline |
||||
sessionTable map[string]*Session |
||||
sessionByBusIDTable map[string]*Session |
||||
sessionSinkTable map[string]Sink |
||||
duration time.Duration |
||||
defaultSinkID string |
||||
} |
||||
|
||||
func NewPipelineManager(busManager BusManager, sessionStore SessionStore, userStore UserStore, sessionCreator SessionCreator) PipelineManager { |
||||
plm := &pipelineManager{ |
||||
BusManager: busManager, |
||||
SessionStore: sessionStore, |
||||
UserStore: userStore, |
||||
SessionCreator: sessionCreator, |
||||
pipelineTable: make(map[string]*Pipeline), |
||||
sessionTable: make(map[string]*Session), |
||||
sessionByBusIDTable: make(map[string]*Session), |
||||
sessionSinkTable: make(map[string]Sink), |
||||
duration: 60 * time.Second, |
||||
} |
||||
plm.start() |
||||
|
||||
plm.Subscribe("channelling.session.create", plm.sessionCreate) |
||||
plm.Subscribe("channelling.session.close", plm.sessionClose) |
||||
|
||||
return plm |
||||
} |
||||
|
||||
func (plm *pipelineManager) cleanup() { |
||||
plm.mutex.Lock() |
||||
for id, pipeline := range plm.pipelineTable { |
||||
if pipeline.Expired() { |
||||
pipeline.Close() |
||||
delete(plm.pipelineTable, id) |
||||
} |
||||
} |
||||
plm.mutex.Unlock() |
||||
} |
||||
|
||||
func (plm *pipelineManager) start() { |
||||
c := time.Tick(30 * time.Second) |
||||
go func() { |
||||
for _ = range c { |
||||
plm.cleanup() |
||||
} |
||||
}() |
||||
} |
||||
|
||||
func (plm *pipelineManager) sessionCreate(subject, reply string, msg *SessionCreateRequest) { |
||||
log.Println("sessionCreate via NATS", subject, reply, msg) |
||||
|
||||
if msg.Session == nil || msg.Id == "" { |
||||
return |
||||
} |
||||
|
||||
var sink Sink |
||||
|
||||
plm.mutex.Lock() |
||||
session, ok := plm.sessionByBusIDTable[msg.Id] |
||||
if ok { |
||||
// Remove existing session with same ID.
|
||||
delete(plm.sessionTable, session.Id) |
||||
sink, _ = plm.sessionSinkTable[session.Id] |
||||
delete(plm.sessionSinkTable, session.Id) |
||||
session.Close() |
||||
} |
||||
session = plm.CreateSession(nil, "") |
||||
plm.sessionByBusIDTable[msg.Id] = session |
||||
plm.sessionTable[session.Id] = session |
||||
if sink == nil { |
||||
sink = plm.CreateSink(msg.Id) |
||||
log.Println("Created NATS sink", msg.Id) |
||||
} |
||||
if reply != "" { |
||||
// Always reply with our sink data
|
||||
plm.Publish(reply, sink.Export()) |
||||
} |
||||
plm.sessionSinkTable[session.Id] = sink |
||||
|
||||
if msg.SetAsDefault { |
||||
plm.defaultSinkID = session.Id |
||||
log.Println("Using NATS sink as default session", session.Id) |
||||
} |
||||
plm.mutex.Unlock() |
||||
|
||||
if msg.Session.Status != nil { |
||||
session.Status = msg.Session.Status |
||||
} |
||||
|
||||
if msg.Session.Userid != "" { |
||||
session.SetUseridFake(msg.Session.Userid) |
||||
} |
||||
|
||||
if msg.Room != nil { |
||||
room, err := session.JoinRoom(msg.Room.Name, msg.Room.Type, msg.Room.Credentials, nil) |
||||
log.Println("Joined NATS session to room", room, err) |
||||
} |
||||
|
||||
session.BroadcastStatus() |
||||
} |
||||
|
||||
func (plm *pipelineManager) sessionClose(subject, reply string, id string) { |
||||
log.Println("sessionClose via NATS", subject, reply, id) |
||||
|
||||
if id == "" { |
||||
return |
||||
} |
||||
|
||||
plm.mutex.Lock() |
||||
session, ok := plm.sessionByBusIDTable[id] |
||||
if ok { |
||||
delete(plm.sessionByBusIDTable, id) |
||||
delete(plm.sessionTable, session.Id) |
||||
if sink, ok := plm.sessionSinkTable[session.Id]; ok { |
||||
delete(plm.sessionSinkTable, session.Id) |
||||
sink.Close() |
||||
} |
||||
} |
||||
plm.mutex.Unlock() |
||||
|
||||
if ok { |
||||
session.Close() |
||||
} |
||||
} |
||||
|
||||
func (plm *pipelineManager) GetPipelineByID(id string) (*Pipeline, bool) { |
||||
plm.mutex.RLock() |
||||
pipeline, ok := plm.pipelineTable[id] |
||||
plm.mutex.RUnlock() |
||||
return pipeline, ok |
||||
} |
||||
|
||||
func (plm *pipelineManager) PipelineID(namespace string, sender Sender, session *Session, to string) string { |
||||
return fmt.Sprintf("%s.%s.%s", namespace, session.Id, to) |
||||
} |
||||
|
||||
func (plm *pipelineManager) GetPipeline(namespace string, sender Sender, session *Session, to string) *Pipeline { |
||||
id := plm.PipelineID(namespace, sender, session, to) |
||||
|
||||
plm.mutex.Lock() |
||||
pipeline, ok := plm.pipelineTable[id] |
||||
if ok { |
||||
// Refresh. We do not care if the pipeline is expired.
|
||||
pipeline.Refresh(plm.duration) |
||||
plm.mutex.Unlock() |
||||
return pipeline |
||||
} |
||||
|
||||
log.Println("Creating pipeline", namespace, id) |
||||
pipeline = NewPipeline(plm, namespace, id, session, plm.duration) |
||||
plm.pipelineTable[id] = pipeline |
||||
plm.mutex.Unlock() |
||||
|
||||
return pipeline |
||||
} |
||||
|
||||
func (plm *pipelineManager) FindSinkAndSession(to string) (sink Sink, session *Session) { |
||||
plm.mutex.RLock() |
||||
|
||||
var found bool |
||||
if sink, found = plm.sessionSinkTable[to]; found { |
||||
session, _ = plm.sessionTable[to] |
||||
plm.mutex.RUnlock() |
||||
if sink.Enabled() { |
||||
log.Println("Pipeline sink found via manager", sink) |
||||
return sink, session |
||||
} |
||||
} else { |
||||
plm.mutex.RUnlock() |
||||
} |
||||
|
||||
if plm.defaultSinkID != "" && to != plm.defaultSinkID { |
||||
// Keep target to while returning a the default sink.
|
||||
log.Println("Find sink via default sink ID", plm.defaultSinkID) |
||||
sink, _ = plm.FindSinkAndSession(plm.defaultSinkID) |
||||
if sink != nil { |
||||
if session, found = plm.GetSession(to); found { |
||||
return |
||||
} |
||||
} |
||||
} |
||||
|
||||
return nil, nil |
||||
} |
@ -0,0 +1,98 @@
@@ -0,0 +1,98 @@
|
||||
/* |
||||
* Spreed WebRTC. |
||||
* Copyright (C) 2013-2015 struktur AG |
||||
* |
||||
* This file is part of Spreed WebRTC. |
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU Affero General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* |
||||
*/ |
||||
|
||||
package server |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"net/http" |
||||
"strconv" |
||||
|
||||
"github.com/strukturag/spreed-webrtc/go/channelling" |
||||
|
||||
"github.com/gorilla/mux" |
||||
) |
||||
|
||||
type Pipelines struct { |
||||
channelling.PipelineManager |
||||
API channelling.ChannellingAPI |
||||
} |
||||
|
||||
func (pipelines *Pipelines) Get(request *http.Request) (int, interface{}, http.Header) { |
||||
vars := mux.Vars(request) |
||||
id, ok := vars["id"] |
||||
if !ok { |
||||
return http.StatusNotFound, "", nil |
||||
} |
||||
|
||||
pipeline, ok := pipelines.GetPipelineByID(id) |
||||
if !ok { |
||||
return http.StatusNotFound, "", nil |
||||
} |
||||
|
||||
since := 0 |
||||
limit := 0 |
||||
if sinceParam := request.Form.Get("since"); sinceParam != "" { |
||||
since, _ = strconv.Atoi(sinceParam) |
||||
} |
||||
if limitParam := request.Form.Get("limit"); limitParam != "" { |
||||
limit, _ = strconv.Atoi(limitParam) |
||||
} |
||||
|
||||
result, err := pipeline.JSONFeed(since, limit) |
||||
if err != nil { |
||||
return http.StatusInternalServerError, err.Error(), nil |
||||
} |
||||
|
||||
return http.StatusOK, result, nil |
||||
} |
||||
|
||||
func (pipelines *Pipelines) Post(request *http.Request) (int, interface{}, http.Header) { |
||||
vars := mux.Vars(request) |
||||
id, ok := vars["id"] |
||||
if !ok { |
||||
return http.StatusNotFound, "", nil |
||||
} |
||||
|
||||
pipeline, ok := pipelines.GetPipelineByID(id) |
||||
if !ok { |
||||
return http.StatusNotFound, "", nil |
||||
} |
||||
|
||||
var incoming channelling.DataIncoming |
||||
dec := json.NewDecoder(request.Body) |
||||
if err := dec.Decode(&incoming); err != nil { |
||||
return http.StatusBadRequest, err.Error(), nil |
||||
} |
||||
|
||||
result := &channelling.DataOutgoing{ |
||||
From: pipeline.FromSession().Id, |
||||
Iid: incoming.Iid, |
||||
} |
||||
reply, err := pipelines.API.OnIncoming(pipeline, pipeline.ToSession(), &incoming) |
||||
if err == nil { |
||||
result.Data = reply |
||||
} else { |
||||
result.Data = err |
||||
} |
||||
|
||||
return http.StatusOK, result, nil |
||||
} |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
/* |
||||
* Spreed WebRTC. |
||||
* Copyright (C) 2013-2015 struktur AG |
||||
* |
||||
* This file is part of Spreed WebRTC. |
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU Affero General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* |
||||
*/ |
||||
|
||||
package channelling |
||||
|
||||
type SessionCreator interface { |
||||
CreateSession(st *SessionToken, userid string) *Session |
||||
} |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
/* |
||||
* Spreed WebRTC. |
||||
* Copyright (C) 2013-2015 struktur AG |
||||
* |
||||
* This file is part of Spreed WebRTC. |
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU Affero General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* |
||||
*/ |
||||
|
||||
package channelling |
||||
|
||||
import ( |
||||
"github.com/nats-io/nats" |
||||
) |
||||
|
||||
// Sink connects a Pipeline with end points in both directions by
|
||||
// getting attached to a Pipeline.
|
||||
type Sink interface { |
||||
// Write sends outgoing data on the sink
|
||||
Write(*DataSinkOutgoing) error |
||||
Enabled() bool |
||||
Close() |
||||
Export() *DataSink |
||||
BindRecvChan(channel interface{}) (*nats.Subscription, error) |
||||
} |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
/* |
||||
* Spreed WebRTC. |
||||
* Copyright (C) 2013-2015 struktur AG |
||||
* |
||||
* This file is part of Spreed WebRTC. |
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU Affero General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* |
||||
*/ |
||||
|
||||
package channelling |
||||
|
||||
type UserStore interface { |
||||
GetUser(id string) (user *User, ok bool) |
||||
} |
Loading…
Reference in new issue