Example #1
0
package main

import (
	"flag"
	"fmt"
	"github.com/trevex/golem"
	"log"
	"net/http"
)

var addr = flag.String("addr", ":8080", "http service address")

// Create room manager
var myroommanager = golem.NewRoomManager()

// Every join and leave request will specify the name of the room
// the connection wants to join or leave.
type RoomRequest struct {
	Name string `json:"name"`
}

// On join, join the room with the specified name.
func join(conn *golem.Connection, data *RoomRequest) {
	fmt.Println("Joining", data.Name)
	myroommanager.Join(data.Name, conn)
}

// On leave, leave the specified room.
func leave(conn *golem.Connection, data *RoomRequest) {
	fmt.Println("Leaving", data.Name)
	myroommanager.Leave(data.Name, conn)
Example #2
0
	domain      = "hanabi.ddns.net"
	auth0Domain = "isaacserver.auth0.com"
	useSSL      = true
	sslCertFile = "/etc/letsencrypt/live/hanabi.ddns.net/fullchain.pem"
	sslKeyFile  = "/etc/letsencrypt/live/hanabi.ddns.net/privkey.pem"
)

/*
 *  Global variables
 */

var (
	projectPath   = os.Getenv("GOPATH") + "/src/github.com/Zamiell/hanabi-server"
	log           = logging.MustGetLogger("hanabi")
	sessionStore  *sessions.CookieStore
	roomManager   = golem.NewRoomManager()
	pmManager     = golem.NewRoomManager()
	commandMutex  = &sync.Mutex{} // Used to prevent race conditions
	connectionMap = make(map[string]*ExtendedConnection)
	chatRoomMap   = make(map[string][]User)
	gameMap       = make(map[int]*GameState)
	db            *models.Models
)

/*
 *  Program entry point
 */

func main() {
	// Configure logging: http://godoc.org/github.com/op/go-logging#Formatter
	loggingBackend := logging.NewLogBackend(os.Stdout, "", 0)