Skip to content

Commit

Permalink
Fixing examples code
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrique Oelze committed Jul 23, 2021
1 parent 9f22f97 commit 90724cc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/demo/chat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func main() {
builder := pitaya.NewDefaultBuilder(true, "chat", pitaya.Cluster, map[string]string{}, conf)
builder.AddAcceptor(acceptor.NewWSAcceptor(":3250"))
builder.Groups = groups.NewMemoryGroupService(config.NewDefaultMemoryGroupConfig())
app := builder.Build()
app = builder.Build()

defer app.Shutdown()

Expand Down
5 changes: 3 additions & 2 deletions examples/demo/cluster/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ func main() {

builder := pitaya.NewDefaultBuilder(*isFrontend, *svType, pitaya.Cluster, map[string]string{}, config.NewDefaultBuilderConfig())
if *isFrontend {
tcp := acceptor.NewTCPAcceptor(fmt.Sprintf(":%d", port))
println(port)
tcp := acceptor.NewTCPAcceptor(fmt.Sprintf(":%d", *port))
builder.AddAcceptor(tcp)
}
builder.Groups = groups.NewMemoryGroupService(config.NewDefaultMemoryGroupConfig())
app := builder.Build()
app = builder.Build()

defer app.Shutdown()

Expand Down
7 changes: 5 additions & 2 deletions examples/demo/cluster_grpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"github.com/topfreegames/pitaya/v2/route"
)

var app pitaya.Pitaya

func configureBackend() {
room := services.NewRoom(app)
app.Register(room,
Expand Down Expand Up @@ -73,7 +75,7 @@ func configureFrontend(port int) {
}
}

var app pitaya.Pitaya


func main() {
port := flag.Int("port", 3250, "the port to listen")
Expand All @@ -88,7 +90,8 @@ func main() {
constants.GRPCPortKey: strconv.Itoa(*rpcServerPort),
}

app, bs := createApp(*port, *isFrontend, *svType, meta, *rpcServerPort)
var bs *modules.ETCDBindingStorage
app, bs = createApp(*port, *isFrontend, *svType, meta, *rpcServerPort)

defer app.Shutdown()

Expand Down
4 changes: 2 additions & 2 deletions examples/demo/cluster_protobuf/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ func main() {

builder := pitaya.NewDefaultBuilder(*isFrontend, *svType, pitaya.Cluster, map[string]string{}, config.NewDefaultBuilderConfig())
if *isFrontend {
ws := acceptor.NewWSAcceptor(fmt.Sprintf(":%d", port))
ws := acceptor.NewWSAcceptor(fmt.Sprintf(":%d", *port))
builder.AddAcceptor(ws)
}
builder.Serializer = protobuf.NewSerializer()
builder.Groups = groups.NewMemoryGroupService(config.NewDefaultMemoryGroupConfig())
app := builder.Build()
app = builder.Build()

defer app.Shutdown()

Expand Down
4 changes: 2 additions & 2 deletions examples/demo/pipeline/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (g *MetagameServer) HandlerNoArg(ctx context.Context) (*HandlerNoArgRespons
// IMPORTANT: that this kind of pipeline will be hard to exist in real code
// as a pipeline function executes for every handler and each of them
// most probably have different parameter types.
func (g *MetagameServer) simpleBefore(ctx context.Context, in interface{}) (context.Context, interface{}, error) {
func (g *MetagameServer) simpleBefore(ctx context.Context, in interface{}) (interface{}, error) {
logger := pitaya.GetDefaultLoggerFromCtx(ctx)
logger.Info("Simple Before exec")

Expand All @@ -76,7 +76,7 @@ func (g *MetagameServer) simpleBefore(ctx context.Context, in interface{}) (cont
logger.Infof("SoftCurrency: %d", createPlayerArgs.SoftCurrency)
logger.Infof("HardCurrency: %d", createPlayerArgs.HardCurrency)
}
return ctx, in, nil
return in, nil
}

// Simple example of an after pipeline. The 2nd argument is the handler response.
Expand Down

0 comments on commit 90724cc

Please sign in to comment.