Golang community are discuting a vendor aproach to go dependencies. This change will come as experimental in go 1.5. For now I am removing the godep dependency manager and using a vendor aproach. I still have to use the full path when importing dependencies, but when go1.5 released I just have to rename the imports and use a -vendor prefix when building the project.
36 lines
933 B
Go
36 lines
933 B
Go
// Copyright 2014 Claudemiro Alves Feitosa Neto. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package ipe
|
|
|
|
import (
|
|
"time"
|
|
|
|
log "github.com/dimiro1/ipe/vendor/github.com/golang/glog"
|
|
"github.com/dimiro1/ipe/vendor/github.com/gorilla/websocket"
|
|
)
|
|
|
|
// An User Connection
|
|
type connection struct {
|
|
SocketID string
|
|
Socket *websocket.Conn
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
// Create a new Subscriber
|
|
func newConnection(socketID string, s *websocket.Conn) *connection {
|
|
log.Infof("Creating a new Subscriber %+v", socketID)
|
|
|
|
return &connection{SocketID: socketID, Socket: s, CreatedAt: time.Now()}
|
|
}
|
|
|
|
// Publish the message to websocket atached to this client
|
|
func (conn *connection) Publish(m interface{}) {
|
|
go func() {
|
|
if err := conn.Socket.WriteJSON(m); err != nil {
|
|
log.Errorf("Error publishing message to connection %+v, %s", conn, err)
|
|
}
|
|
}()
|
|
}
|