pitaya icon indicating copy to clipboard operation
pitaya copied to clipboard

How to kick out a user with a message

Open NicholasChan1025 opened this issue 4 years ago • 5 comments

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

NicholasChan1025 avatar Dec 15 '20 09:12 NicholasChan1025

you are right, as of now you can't send payloads during Kick, if you want to implemennt this, a PR would be welcome

felipejfc avatar Dec 16 '20 16:12 felipejfc

I can't find the protobuf file corresponding to kick.pb.go, where can I get that file please

NicholasChan1025 avatar Dec 18 '20 04:12 NicholasChan1025

in this repo : github.com/topfreegames/pitaya-protos

@NicholasChan1025

chgz avatar Dec 25 '20 03:12 chgz

My client code subscribe an "onKicked" event, and server just push "onKicked" event to client before kick it.

greatcat-taihe avatar Jan 05 '21 11:01 greatcat-taihe

My client code subscribe an "onKicked" event, and server just push "onKicked" event to client before kick it.

You may not receive this message

f2ngwx avatar Sep 25 '22 05:09 f2ngwx