mirror of
https://git.mills.io/saltyim/saltyim.git
synced 2024-06-30 18:51:03 +00:00
![xuu](/assets/img/avatar_default.png)
I added sha256 for discovery and fallback ability. And implemented sending message using msgbus. Co-authored-by: Jon Lundy <jon@xuu.cc> Reviewed-on: https://git.mills.io/prologic/salty-chat/pulls/8 Co-authored-by: xuu <xuu@noreply@mills.io> Co-committed-by: xuu <xuu@noreply@mills.io>
21 lines
430 B
Go
21 lines
430 B
Go
package saltyim
|
|
|
|
import (
|
|
"strings"
|
|
|
|
msgbus_client "git.mills.io/prologic/msgbus/client"
|
|
)
|
|
|
|
func Send(endpoint, msg string) error {
|
|
uri, topic := splitTopic(endpoint)
|
|
client := msgbus_client.NewClient(uri, nil)
|
|
return client.Publish(topic, msg)
|
|
}
|
|
|
|
func splitTopic(endpoint string) (string, string) {
|
|
if idx := strings.LastIndex(endpoint, "/"); idx != -1 {
|
|
return endpoint[:idx], endpoint[idx+1:]
|
|
}
|
|
return endpoint, ""
|
|
}
|