Skip to content
Snippets Groups Projects
Select Git revision
  • 18a4efddd35b2ccc9e861334d05a86b4412a26ee
  • release default protected
  • 11-22-implement-kv-interface-defined-in-collectiveversionedkvgo
  • hotfix/TestHostPool_UpdateNdf_AddFilter
  • XX-4719/announcementChannels
  • xx-4717/logLevel
  • jonah/noob-channel
  • master protected
  • XX-4707/tagDiskJson
  • xx-4698/notification-retry
  • hotfix/notifylockup
  • syncNodes
  • hotfix/localCB
  • XX-4677/NewChanManagerMobile
  • XX-4689/DmSync
  • duplicatePrefix
  • XX-4601/HavenInvites
  • finalizedUICallbacks
  • XX-4673/AdminKeySync
  • debugNotifID
  • anne/test
  • v4.7.5
  • v4.7.4
  • v4.7.3
  • v4.7.2
  • v4.7.1
  • v4.6.3
  • v4.6.1
  • v4.5.0
  • v4.4.4
  • v4.3.11
  • v4.3.8
  • v4.3.7
  • v4.3.6
  • v4.3.5
  • v4.2.0
  • v4.3.0
  • v4.3.4
  • v4.3.3
  • v4.3.2
  • v4.3.1
41 results

switchboard.go

Blame
  • switchboard.go 3.17 KiB
    ///////////////////////////////////////////////////////////////////////////////
    // Copyright © 2020 xx network SEZC                                          //
    //                                                                           //
    // Use of this source code is governed by a license that can be found in the //
    // LICENSE file                                                              //
    ///////////////////////////////////////////////////////////////////////////////
    
    package interfaces
    
    import (
    	"gitlab.com/elixxir/client/interfaces/message"
    	"gitlab.com/elixxir/client/switchboard"
    	"gitlab.com/xx_network/primitives/id"
    )
    
    // public switchboard interface which only allows registration and does not
    // allow speaking messages
    type Switchboard interface {
    	// Registers a new listener. Returns the ID of the new listener.
    	// Keep this around if you want to be able to delete the listener later.
    	//
    	// name is used for debug printing and not checked for uniqueness
    	//
    	// user: 0 for all, or any user ID to listen for messages from a particular
    	// user. 0 can be id.ZeroUser or id.ZeroID
    	// messageType: 0 for all, or any message type to listen for messages of
    	// that type. 0 can be switchboard.AnyType
    	// newListener: something implementing the Listener interface. Do not
    	// pass nil to this.
    	//
    	// If a message matches multiple listeners, all of them will hear the
    	// message.
    	RegisterListener(user *id.ID, messageType message.Type,
    		newListener switchboard.Listener) switchboard.ListenerID
    
    	// Registers a new listener built around the passed function.
    	// Returns the ID of the new listener.
    	// Keep this around if you want to be able to delete the listener later.
    	//
    	// name is used for debug printing and not checked for uniqueness
    	//
    	// user: 0 for all, or any user ID to listen for messages from a particular
    	// user. 0 can be id.ZeroUser or id.ZeroID
    	// messageType: 0 for all, or any message type to listen for messages of
    	// that type. 0 can be switchboard.AnyType
    	// newListener: a function implementing the ListenerFunc function type.
    	// Do not pass nil to this.
    	//
    	// If a message matches multiple listeners, all of them will hear the
    	// message.
    	RegisterFunc(name string, user *id.ID, messageType message.Type,
    		newListener switchboard.ListenerFunc) switchboard.ListenerID
    
    	// Registers a new listener built around the passed channel.
    	// Returns the ID of the new listener.
    	// Keep this around if you want to be able to delete the listener later.
    	//
    	// name is used for debug printing and not checked for uniqueness
    	//
    	// user: 0 for all, or any user ID to listen for messages from a particular
    	// user. 0 can be id.ZeroUser or id.ZeroID
    	// messageType: 0 for all, or any message type to listen for messages of
    	// that type. 0 can be switchboard.AnyType
    	// newListener: an item channel.
    	// Do not pass nil to this.
    	//
    	// If a message matches multiple listeners, all of them will hear the
    	// message.
    	RegisterChannel(name string, user *id.ID, messageType message.Type,
    		newListener chan message.Receive) switchboard.ListenerID
    
    	// Unregister removes the listener with the specified ID so it will no
    	// longer get called
    	Unregister(listenerID switchboard.ListenerID)
    }