This repository has been archived by the owner on Jan 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
42 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package net | ||
|
||
// MessageSender is the interface that abstracts the network | ||
// interactions. | ||
type MessageSender interface { | ||
// SendToClient tries to deliver the message "msg" to the client i. | ||
SendToClient(i int, msg interface{}) error | ||
|
||
// SendToTrustee tries to deliver the message "msg" to the trustee i. | ||
SendToTrustee(i int, msg interface{}) error | ||
|
||
// SendToRelay tries to deliver the message "msg" to the relay. | ||
SendToRelay(msg interface{}) error | ||
|
||
/* | ||
BroadcastToAllClients tries to deliver the message "msg" | ||
to every client, possibly using broadcast. | ||
*/ | ||
BroadcastToAllClients(msg interface{}) error | ||
|
||
/* | ||
ClientSubscribeToBroadcast should be called by the Clients | ||
in order to receive the Broadcast messages. | ||
Calling the function starts the handler but does not actually | ||
listen for broadcast messages. | ||
Sending true to startStopChan starts receiving the broadcasts. | ||
Sending false to startStopChan stops receiving the broadcasts. | ||
*/ | ||
ClientSubscribeToBroadcast(clientName string, messageReceived func(interface{}) error, startStopChan chan bool) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters