Add OnDisconnect event
This commit is contained in:
parent
733e00d6f9
commit
1c317fc186
|
@ -101,6 +101,8 @@ func (r *Ricochet) ProcessMessages(service RicochetService) {
|
|||
// to process them.
|
||||
func (r *Ricochet) processConnection(oc *OpenConnection, service RicochetService) {
|
||||
service.OnConnect(oc)
|
||||
defer service.OnDisconnect(oc)
|
||||
|
||||
for {
|
||||
if oc.Closed {
|
||||
return
|
||||
|
|
|
@ -4,6 +4,7 @@ package goricochet
|
|||
type RicochetService interface {
|
||||
OnReady()
|
||||
OnConnect(oc *OpenConnection)
|
||||
OnDisconnect(oc *OpenConnection)
|
||||
|
||||
// Authentication Management
|
||||
OnAuthenticationRequest(oc *OpenConnection, channelID int32, clientCookie [16]byte)
|
||||
|
|
|
@ -84,6 +84,10 @@ func (srs *StandardRicochetService) OnConnect(oc *OpenConnection) {
|
|||
}
|
||||
}
|
||||
|
||||
// OnDisconnect is called when a connection is closed
|
||||
func (srs *StandardRicochetService) OnDisconnect(oc *OpenConnection) {
|
||||
}
|
||||
|
||||
// OnAuthenticationRequest is called when a client requests Authentication
|
||||
func (srs *StandardRicochetService) OnAuthenticationRequest(oc *OpenConnection, channelID int32, clientCookie [16]byte) {
|
||||
oc.ConfirmAuthChannel(channelID, clientCookie)
|
||||
|
|
Loading…
Reference in New Issue