From 9308a51800b986a58c3b11ba43f63a337d35bccf Mon Sep 17 00:00:00 2001 From: braginini Date: Tue, 15 Jun 2021 19:02:46 +0200 Subject: [PATCH] refactor: rename SignalExchangeServer to Server to comply with good practices --- signal/signal.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/signal/signal.go b/signal/signal.go index 2c3101e2e..91aa9edd9 100644 --- a/signal/signal.go +++ b/signal/signal.go @@ -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) @@ -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 @@ -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)