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.
|
// to process them.
|
||||||
func (r *Ricochet) processConnection(oc *OpenConnection, service RicochetService) {
|
func (r *Ricochet) processConnection(oc *OpenConnection, service RicochetService) {
|
||||||
service.OnConnect(oc)
|
service.OnConnect(oc)
|
||||||
|
defer service.OnDisconnect(oc)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if oc.Closed {
|
if oc.Closed {
|
||||||
return
|
return
|
||||||
|
|
|
@ -4,6 +4,7 @@ package goricochet
|
||||||
type RicochetService interface {
|
type RicochetService interface {
|
||||||
OnReady()
|
OnReady()
|
||||||
OnConnect(oc *OpenConnection)
|
OnConnect(oc *OpenConnection)
|
||||||
|
OnDisconnect(oc *OpenConnection)
|
||||||
|
|
||||||
// Authentication Management
|
// Authentication Management
|
||||||
OnAuthenticationRequest(oc *OpenConnection, channelID int32, clientCookie [16]byte)
|
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
|
// OnAuthenticationRequest is called when a client requests Authentication
|
||||||
func (srs *StandardRicochetService) OnAuthenticationRequest(oc *OpenConnection, channelID int32, clientCookie [16]byte) {
|
func (srs *StandardRicochetService) OnAuthenticationRequest(oc *OpenConnection, channelID int32, clientCookie [16]byte) {
|
||||||
oc.ConfirmAuthChannel(channelID, clientCookie)
|
oc.ConfirmAuthChannel(channelID, clientCookie)
|
||||||
|
|
Loading…
Reference in New Issue