Skip to content
Snippets Groups Projects
Commit d2fe0add authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Add ResetSession and associated callback to bindings

parent 496edd9f
No related branches found
No related tags found
2 merge requests!231Revert "Update store to print changes to the partners list",!171RestoreContactsFromBackup
......@@ -58,16 +58,44 @@ func (c *Client) RequestAuthenticatedChannel(recipientMarshaled,
return int(rid), err
}
// RegisterAuthCallbacks registers both callbacks for authenticated channels.
// ResetSession resets an authenticated channel that already exists
func (c *Client) ResetSession(recipientMarshaled,
meMarshaled []byte, message string) (int, error) {
recipent, err := contact.Unmarshal(recipientMarshaled)
if err != nil {
return 0, fmt.Errorf("failed to "+
"ResetSession: failed to Unmarshal Recipent: "+
"%+v", err)
}
me, err := contact.Unmarshal(meMarshaled)
if err != nil {
return 0, fmt.Errorf("failed to "+
"ResetSession: Failed to Unmarshal Me: %+v", err)
}
rid, err := c.api.ResetSession(recipent, me, message)
return int(rid), err
}
// RegisterAuthCallbacks registers all callbacks for authenticated channels.
// This can only be called once
func (c *Client) RegisterAuthCallbacks(request AuthRequestCallback,
confirm AuthConfirmCallback) {
confirm AuthConfirmCallback, reset AuthResetCallback) {
requestFunc := func(requestor contact.Contact) {
requestorBind := &Contact{c: &requestor}
request.Callback(requestorBind)
}
resetFunc := func(resetor contact.Contact) {
resetorBind := &Contact{c: &resetor}
reset.Callback(resetorBind)
}
confirmFunc := func(partner contact.Contact) {
partnerBind := &Contact{c: &partner}
confirm.Callback(partnerBind)
......@@ -75,8 +103,7 @@ func (c *Client) RegisterAuthCallbacks(request AuthRequestCallback,
c.api.GetAuthRegistrar().AddGeneralConfirmCallback(confirmFunc)
c.api.GetAuthRegistrar().AddGeneralRequestCallback(requestFunc)
return
c.api.GetAuthRegistrar().AddResetCallback(resetFunc)
}
// ConfirmAuthenticatedChannel creates an authenticated channel out of a valid
......
......@@ -60,6 +60,12 @@ type AuthConfirmCallback interface {
Callback(partner *Contact)
}
// AuthRequestCallback notifies the register whenever they receive an auth
// request
type AuthResetCallback interface {
Callback(requestor *Contact)
}
// Generic Unregister - a generic return used for all callbacks which can be
// unregistered
// Interface which allows the un-registration of a listener
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment