Created
July 12, 2020 03:32
-
-
Save dipeshdulal/65ab0df2d86a58cd119c5d3ee69046ab to your computer and use it in GitHub Desktop.
SendMessage
This file contains hidden or 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
func (s *chatServiceServer) SendMessage(msgStream chatpb.ChatService_SendMessageServer) error { | |
msg, err := msgStream.Recv() | |
if err == io.EOF { | |
return nil | |
} | |
if err != nil { | |
return err | |
} | |
ack := chatpb.MessageAck{Status: "SENT"} | |
msgStream.SendAndClose(&ack) | |
go func() { | |
streams := s.channel[msg.Channel.Name] | |
for _, msgChan := range streams { | |
msgChan <- msg | |
} | |
}() | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment