pitaya
pitaya copied to clipboard
How to kick out a user with a message
There are several situations where users need to be kicked offline For example 1: Login from other clients 2: The administrator thinks the user's account is abnormal 3: The server side needs urgent maintenance And so on
At this time, the Kick method should carry a specific description, so that the client can make different prompts for different kick types
session.go
// Kick kicks the user func (s *Session) Kick(ctx context.Context) error { err := s.entity.Kick(ctx) if err != nil { return err } return s.entity.Close() }
agent.go
// Kick sends a kick packet to a client func (a *Agent) Kick(ctx context.Context) error { // packet encode p, err := a.encoder.Encode(packet.Kick, nil) if err != nil { return err } _, err = a.conn.Write(p) return err }
The methods in the session and agent package cannot carry custom information
you are right, as of now you can't send payloads during Kick, if you want to implemennt this, a PR would be welcome
I can't find the protobuf file corresponding to kick.pb.go, where can I get that file please
in this repo : github.com/topfreegames/pitaya-protos
@NicholasChan1025
My client code subscribe an "onKicked" event, and server just push "onKicked" event to client before kick it.
My client code subscribe an "onKicked" event, and server just push "onKicked" event to client before kick it.
You may not receive this message