Add OnDisconnect event

This commit is contained in:
John Brooks 2016-10-01 15:52:35 -07:00 committed by Sarah Jamie Lewis
parent 733e00d6f9
commit 1c317fc186
3 changed files with 7 additions and 0 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)