Skip to content

Commit

Permalink
fix rpc call can receive a pointer, duh
Browse files Browse the repository at this point in the history
  • Loading branch information
felipejfc committed Mar 21, 2018
1 parent dbb6f79 commit 0073953
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

package component

import "github.com/topfreegames/pitaya/logger"

var log = logger.Log

// Component is the interface that represent a component.
type Component interface {
Init()
Expand Down
10 changes: 5 additions & 5 deletions examples/demo/cluster/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,20 @@ func (r *Room) SendRPC(s *session.Session, msg *RPCMessage) error {
str := "AE PQP"
res, err := pitaya.RPC("room.room.messageremote", &UserMessage{}, mmsg, b, str)
if err != nil {
fmt.Printf("rpc error: %s", err)
fmt.Printf("rpc error: %s\n", err)
return err
}
fmt.Printf("rpc res %s", res)
fmt.Printf("rpc res %s\n", res)
return nil
}

// MessageRemote just echoes the given message
func (r *Room) MessageRemote(msg UserMessage, b bool, s string) (*UserMessage, error) {
func (r *Room) MessageRemote(msg *UserMessage, b bool, s string) (*UserMessage, error) {
fmt.Println("CHEGOU", b, s)
if b {
return nil, fmt.Errorf("FUCK")
}
return &msg, nil
return msg, nil
}

// StatsRemote returns a room stats
Expand All @@ -162,7 +162,7 @@ func (r *Room) StatsRemote() (*stats, error) {
}

func registerGobInterfaces() {
gob.Register(UserMessage{})
gob.Register(&UserMessage{})
}

func main() {
Expand Down

0 comments on commit 0073953

Please sign in to comment.