Skip to content

Commit

Permalink
refactor: rename SignalExchangeServer to Server to comply with good p…
Browse files Browse the repository at this point in the history
…ractices
  • Loading branch information
braginini committed Jun 15, 2021
1 parent fc80979 commit f3547e2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions signal/signal.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ import (
"io"
)

// SignalExchangeServer an instance of a Signal server
type SignalExchangeServer struct {
// Server an instance of a Signal server
type Server struct {
registry *peer.Registry
}

// NewServer creates a new Signal server
func NewServer() *SignalExchangeServer {
return &SignalExchangeServer{
func NewServer() *Server {
return &Server{
registry: peer.NewRegistry(),
}
}

// Send forwards a message to the signal peer
func (s *SignalExchangeServer) Send(ctx context.Context, msg *proto.EncryptedMessage) (*proto.EncryptedMessage, error) {
func (s *Server) Send(ctx context.Context, msg *proto.EncryptedMessage) (*proto.EncryptedMessage, error) {

if !s.registry.IsPeerRegistered(msg.Key) {
return nil, fmt.Errorf("unknown peer %s", msg.Key)
Expand All @@ -46,7 +46,7 @@ func (s *SignalExchangeServer) Send(ctx context.Context, msg *proto.EncryptedMes
}

// ConnectStream connects to the exchange stream
func (s *SignalExchangeServer) ConnectStream(stream proto.SignalExchange_ConnectStreamServer) error {
func (s *Server) ConnectStream(stream proto.SignalExchange_ConnectStreamServer) error {
p, err := s.connectPeer(stream)
if err != nil {
return err
Expand Down Expand Up @@ -82,7 +82,7 @@ func (s *SignalExchangeServer) ConnectStream(stream proto.SignalExchange_Connect
// Handles initial Peer connection.
// Each connection must provide an ID header.
// At this moment the connecting Peer will be registered in the peer.Registry
func (s SignalExchangeServer) connectPeer(stream proto.SignalExchange_ConnectStreamServer) (*peer.Peer, error) {
func (s Server) connectPeer(stream proto.SignalExchange_ConnectStreamServer) (*peer.Peer, error) {
if meta, hasMeta := metadata.FromIncomingContext(stream.Context()); hasMeta {
if id, found := meta[proto.HeaderId]; found {
p := peer.NewPeer(id[0], stream)
Expand Down

0 comments on commit f3547e2

Please sign in to comment.