Browse Source

Merge branch 'release-0.23'

pull/175/head v0.23.5
Simon Eisenmann 11 years ago
parent
commit
d3e1a8b94d
  1. 19
      Makefile.am
  2. 7
      debian/changelog
  3. 5
      src/app/spreed-webrtc-server/channelling_api.go
  4. 13
      src/app/spreed-webrtc-server/client.go
  5. 2
      src/app/spreed-webrtc-server/connection.go
  6. 25
      src/app/spreed-webrtc-server/hub.go
  7. 5
      src/app/spreed-webrtc-server/session.go
  8. 1
      src/app/spreed-webrtc-server/ws.go

19
Makefile.am

@ -27,15 +27,13 @@ CONFIG_FILE ?= spreed-webrtc-server.conf @@ -27,15 +27,13 @@ CONFIG_FILE ?= spreed-webrtc-server.conf
CONFIG_PATH ?= /etc
GOBUILDFLAGS ?=
GOTESTFLAGS ?=
DESTDIR ?= /
BIN ?= @prefix@/sbin
SHARE ?= @prefix@/share/spreed-webrtc-server
OUTPUT := $(CURDIR)/bin
OUTPUT_JS := $(CURDIR)/build/out
BIN := $(DESTDIR)@prefix@/sbin
CONFIG_DIR := $(DESTDIR)@prefix@$(CONFIG_PATH)
SHARE := $(DESTDIR)@prefix@/share/spreed-webrtc-server
BUILD_ARCH := $(shell $(GO) env GOARCH)
BUILD_OS := $(shell go env GOOS)
DIST := $(CURDIR)/dist_$(BUILD_ARCH)
@ -119,9 +117,9 @@ release: OUTPUT = $(DIST_BIN) @@ -119,9 +117,9 @@ release: OUTPUT = $(DIST_BIN)
release: $(DIST_BIN) binary releaseassets
install:
echo $(BIN)
echo $(SHARE)
$(INSTALL) -d $(BIN) $(CONFIG_DIR)
@echo "Installing binaries to: $(BIN)"
@echo "Installing static resources to: $(SHARE)"
$(INSTALL) -d $(BIN)
$(INSTALL) -d $(SHARE)/www/html
$(INSTALL) -d $(SHARE)/www/static
$(INSTALL) -d $(SHARE)/www/static/img
@ -131,7 +129,6 @@ install: @@ -131,7 +129,6 @@ install:
$(INSTALL) -d $(SHARE)/www/static/css
$(INSTALL) -d $(SHARE)/www/static/js/libs/pdf
$(INSTALL) bin/$(EXENAME) $(BIN)
$(INSTALL) -m 644 server.conf.in $(CONFIG_DIR)/$(CONFIG_FILE)
$(INSTALL) html/* $(SHARE)/www/html
$(INSTALL) static/img/* $(SHARE)/www/static/img
$(INSTALL) static/sounds/* $(SHARE)/www/static/sounds
@ -166,11 +163,11 @@ $(DIST_BIN): @@ -166,11 +163,11 @@ $(DIST_BIN):
tarball: TARPATH = $(DIST)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
tarball: BIN = $(TARPATH)/loader
tarball: CONFIG_DIR = $(TARPATH)/loader
tarball: DOCS = $(CONFIG_DIR)/docs
tarball: DOCS = $(TARPATH)/loader/docs
tarball: SHARE = $(TARPATH)/
tarball: distclean release install
echo -n $(PACKAGE_VERSION) > $(TARPATH)/version.txt
cp server.conf.in $(TARPATH)/loader
tar czf $(DIST)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)_$(BUILD_OS)_$(BUILD_ARCH).tar.gz -C $(DIST) $(PACKAGE_NAME)-$(PACKAGE_VERSION)
.PHONY: clean distclean vendorclean pristine get getupdate build javascript fonts styles release releasetest dist_gopath install gopath binary binaryrace binaryall tarball assets

7
debian/changelog vendored

@ -1,3 +1,10 @@ @@ -1,3 +1,10 @@
spreed-webrtc-server (0.23.5) precise; urgency=low
* No longer install config file in install target of Makefile. We leave it to the packaging.
* Sessions are no longer cleaned up when another connection replaced the session and a stale connection gets disconnected after that.
-- Simon Eisenmann <simon@struktur.de> Wed, 11 Feb 2015 11:16:47 +0100
spreed-webrtc-server (0.23.4) precise; urgency=low
* Cleanup of README.

5
src/app/spreed-webrtc-server/channelling_api.go

@ -32,6 +32,7 @@ const ( @@ -32,6 +32,7 @@ const (
type ChannellingAPI interface {
OnConnect(Client, *Session)
OnDisconnect(Client, *Session)
OnIncoming(ResponseSender, *Session, *DataIncoming)
}
@ -64,6 +65,10 @@ func (api *channellingAPI) OnConnect(client Client, session *Session) { @@ -64,6 +65,10 @@ func (api *channellingAPI) OnConnect(client Client, session *Session) {
api.SendSelf(client, session)
}
func (api *channellingAPI) OnDisconnect(client Client, session *Session) {
api.Unicaster.OnDisconnect(client, session)
}
func (api *channellingAPI) OnIncoming(c ResponseSender, session *Session, msg *DataIncoming) {
switch msg.Type {
case "Self":

13
src/app/spreed-webrtc-server/client.go

@ -43,6 +43,7 @@ type Client interface { @@ -43,6 +43,7 @@ type Client interface {
Session() *Session
Index() uint64
Close()
ReplaceAndClose()
}
type client struct {
@ -61,6 +62,11 @@ func (client *client) OnConnect(conn Connection) { @@ -61,6 +62,11 @@ func (client *client) OnConnect(conn Connection) {
client.ChannellingAPI.OnConnect(client, client.session)
}
func (client *client) OnDisconnect() {
client.session.Close()
client.ChannellingAPI.OnDisconnect(client, client.session)
}
func (client *client) OnText(b Buffer) {
if incoming, err := client.DecodeIncoming(b); err == nil {
client.OnIncoming(client, client.session, incoming)
@ -81,3 +87,10 @@ func (client *client) Reply(iid string, m interface{}) { @@ -81,3 +87,10 @@ func (client *client) Reply(iid string, m interface{}) {
func (client *client) Session() *Session {
return client.session
}
func (client *client) ReplaceAndClose() {
client.session.Close()
if client.Connection != nil {
client.Connection.Close()
}
}

2
src/app/spreed-webrtc-server/connection.go

@ -64,6 +64,7 @@ type Connection interface { @@ -64,6 +64,7 @@ type Connection interface {
type ConnectionHandler interface {
NewBuffer() Buffer
OnConnect(Connection)
OnDisconnect()
OnText(Buffer)
}
@ -167,6 +168,7 @@ func (c *connection) readPump() { @@ -167,6 +168,7 @@ func (c *connection) readPump() {
}
c.Close()
c.handler.OnDisconnect()
}
// Write message to outbound queue.

25
src/app/spreed-webrtc-server/hub.go

@ -48,8 +48,8 @@ type SessionStore interface { @@ -48,8 +48,8 @@ type SessionStore interface {
type Unicaster interface {
SessionStore
OnConnect(Client, *Session)
OnDisconnect(Client, *Session)
Unicast(to string, outgoing *DataOutgoing)
OnDisconnect(sessionID string)
}
type ContactManager interface {
@ -150,26 +150,27 @@ func (h *hub) GetSession(id string) (session *Session, ok bool) { @@ -150,26 +150,27 @@ func (h *hub) GetSession(id string) (session *Session, ok bool) {
}
func (h *hub) OnConnect(client Client, session *Session) {
// Set flags.
h.mutex.Lock()
log.Printf("Created client with id %s", session.Id)
log.Printf("Created client %d with id %s\n", client.Index(), session.Id)
// Register connection or replace existing one.
if ec, ok := h.clients[session.Id]; ok {
ec.Close()
//log.Printf("Register (%d) from %s: %s (existing)\n", c.Idx, c.Id)
log.Printf("Closing obsolete client %d with id %s\n", ec.Index(), session.Id)
ec.ReplaceAndClose()
}
h.clients[session.Id] = client
//fmt.Println("registered", c.Id)
h.mutex.Unlock()
//log.Printf("Register (%d) from %s: %s\n", c.Idx, c.Id)
}
func (h *hub) OnDisconnect(sessionID string) {
func (h *hub) OnDisconnect(client Client, session *Session) {
h.mutex.Lock()
delete(h.clients, sessionID)
if ec, ok := h.clients[session.Id]; ok {
if ec == client {
log.Printf("Cleaning up client %d for session id %s\n", ec.Index(), session.Id)
delete(h.clients, session.Id)
} else {
log.Printf("Not cleaning up session %s as client %d was replaced with %d\n", session.Id, client.Index(), ec.Index())
}
}
h.mutex.Unlock()
}

5
src/app/spreed-webrtc-server/session.go

@ -204,6 +204,10 @@ func (s *Session) Unicast(to string, m interface{}) { @@ -204,6 +204,10 @@ func (s *Session) Unicast(to string, m interface{}) {
func (s *Session) Close() {
s.mutex.Lock()
if s.disconnected {
s.mutex.Unlock()
return
}
outgoing := &DataOutgoing{
From: s.Id,
@ -230,7 +234,6 @@ func (s *Session) Close() { @@ -230,7 +234,6 @@ func (s *Session) Close() {
session.RemoveSubscriber(s.Id)
}
s.Unicaster.OnDisconnect(s.Id)
s.SessionManager.DestroySession(s.Id, s.userid)
s.buddyImages.Delete(s.Id)

1
src/app/spreed-webrtc-server/ws.go

@ -69,7 +69,6 @@ func makeWSHandler(connectionCounter ConnectionCounter, sessionManager SessionMa @@ -69,7 +69,6 @@ func makeWSHandler(connectionCounter ConnectionCounter, sessionManager SessionMa
// Create a new connection instance.
session := sessionManager.CreateSession(r)
defer session.Close()
client := NewClient(codec, channellingAPI, session)
conn := NewConnection(connectionCounter.CountConnection(), ws, client)

Loading…
Cancel
Save