Commit bcb16735 authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Add JSON encoding support over WebSocket connections. Merge #122

parent bcca141e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -6,9 +6,10 @@ The format is based on [keep a changelog](http://keepachangelog.com/) and this p
## [Unreleased]
### Added
- RUDP transport option for client connections.
- Accept JSON payload over WebSocket connections.

### Changed
- Consistently Use strings for all ID types.
- Consistently use strings for all ID types.
- Improve runtime hook lookup behaviour.

### [1.1.0] - 2017-10-17
+15 −3
Original line number Diff line number Diff line
@@ -32,11 +32,13 @@ import (

	"nakama/pkg/social"

	"runtime"

	"github.com/armon/go-metrics"
	"github.com/gogo/protobuf/jsonpb"
	_ "github.com/lib/pq"
	"github.com/satori/go.uuid"
	"go.uber.org/zap"
	"runtime"
)

const (
@@ -84,11 +86,21 @@ func main() {
	// Check migration status and log if the schema has diverged.
	cmd.MigrationStartupCheck(multiLogger, db)

	jsonpbMarshaler := &jsonpb.Marshaler{
		EnumsAsInts:  true,
		EmitDefaults: false,
		Indent:       "",
		OrigName:     false,
	}
	jsonpbUnmarshaler := &jsonpb.Unmarshaler{
		AllowUnknownFields: false,
	}

	trackerService := server.NewTrackerService(config.GetName())
	statsService := server.NewStatsService(jsonLogger, config, semver, trackerService, startedAt)
	matchmakerService := server.NewMatchmakerService(config.GetName())
	sessionRegistry := server.NewSessionRegistry(jsonLogger, config, trackerService, matchmakerService)
	messageRouter := server.NewMessageRouterService(sessionRegistry)
	messageRouter := server.NewMessageRouterService(jsonpbMarshaler, sessionRegistry)
	presenceNotifier := server.NewPresenceNotifier(jsonLogger, config.GetName(), trackerService, messageRouter)
	trackerService.AddDiffListener(presenceNotifier.HandleDiff)
	notificationService := server.NewNotificationService(jsonLogger, db, trackerService, messageRouter, config.GetSocial().Notification)
@@ -101,7 +113,7 @@ func main() {
	socialClient := social.NewClient(5 * time.Second)
	purchaseService := server.NewPurchaseService(jsonLogger, multiLogger, db, config.GetPurchase())
	pipeline := server.NewPipeline(config, db, trackerService, matchmakerService, messageRouter, sessionRegistry, socialClient, runtimePool, purchaseService, notificationService)
	authService := server.NewAuthenticationService(jsonLogger, config, db, statsService, sessionRegistry, socialClient, pipeline, runtimePool)
	authService := server.NewAuthenticationService(jsonLogger, config, db, jsonpbMarshaler, jsonpbUnmarshaler, statsService, sessionRegistry, socialClient, pipeline, runtimePool)
	dashboardService := server.NewDashboardService(jsonLogger, multiLogger, semver, config, statsService)

	gaenabled := len(os.Getenv("NAKAMA_TELEMETRY")) < 1
+3 −2
Original line number Diff line number Diff line
@@ -34,11 +34,12 @@ package multicode
import (
	"errors"
	"fmt"
	"github.com/wirepair/netcode"
	"go.uber.org/zap"
	"net"
	"sync"
	"time"

	"github.com/wirepair/netcode"
	"go.uber.org/zap"
)

const (
+2 −1
Original line number Diff line number Diff line
@@ -32,9 +32,10 @@
package multicode

import (
	"net"

	"github.com/wirepair/netcode"
	"go.uber.org/zap"
	"net"
)

type NetcodeData struct {
+3 −2
Original line number Diff line number Diff line
@@ -32,12 +32,13 @@
package multicode

import (
	"github.com/wirepair/netcode"
	"go.uber.org/zap"
	"net"
	"sync"
	"sync/atomic"
	"time"

	"github.com/wirepair/netcode"
	"go.uber.org/zap"
)

// Not a true connection limit, only used to initialise/allocate various buffer and data structure sizes.
Loading