Skip to content

Commit 752d317

Browse files
CarsonLenzecooldogedev
authored andcommitted
session/processor.go: pass the disconnection message to ProcessDisconnection() (#28)
1 parent d5cdea2 commit 752d317

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

session/processor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type Processor interface {
4848
// ProcessCache is called before updating the session's cache.
4949
ProcessCache(ctx *Context, new *[]byte)
5050
// ProcessDisconnection is called when the player disconnects from the proxy.
51-
ProcessDisconnection(ctx *Context)
51+
ProcessDisconnection(ctx *Context, message *string)
5252
}
5353

5454
// NopProcessor is a no-operation implementation of the Processor interface.
@@ -67,4 +67,4 @@ func (NopProcessor) ProcessPreTransfer(_ *Context, _ *string, _ *string) {}
6767
func (NopProcessor) ProcessTransferFailure(_ *Context, _ *string, _ *string) {}
6868
func (NopProcessor) ProcessPostTransfer(_ *Context, _ *string, _ *string) {}
6969
func (NopProcessor) ProcessCache(_ *Context, _ *[]byte) {}
70-
func (NopProcessor) ProcessDisconnection(_ *Context) {}
70+
func (NopProcessor) ProcessDisconnection(_ *Context, _ *string) {}

session/session.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,10 @@ func (s *Session) Close() (err error) {
273273

274274
func (s *Session) CloseWithError(err error) {
275275
s.once.Do(func() {
276-
_ = s.client.WritePacket(&packet.Disconnect{Message: err.Error()})
276+
message := err.Error()
277+
s.Processor().ProcessDisconnection(NewContext(), &message)
278+
_ = s.client.WritePacket(&packet.Disconnect{Message: message})
277279
_ = s.client.Close()
278-
s.Processor().ProcessDisconnection(NewContext())
279280
s.serverMu.RLock()
280281
if s.serverConn != nil {
281282
s.serverConn.CloseWithError(err)

0 commit comments

Comments
 (0)