Closed synw closed 7 years ago
@synw hello! Just tried example over Centrifugo and it works. In order to publish from client publish
option must be set to true
in channel namespace configuration - maybe you forgot to set in in config? I.e. try example with Centrifufo using config:
{
"secret": "secret",
"namespaces": [
{
"name": "public",
"publish": true,
"presence": true,
"join_leave": true,
"history_size": 10,
"history_lifetime": 30,
"recover": true
}
]
}
Btw I've seen some cool stuff you've done with Centrifugo - great work, thanks for contributing 👍
Regarding to your wrapper - currently I actively work on centrifuge-mobile which is also in Go (but compiles to Java and Swift). And during the work I found some things that can be improved in current centrifuge-go
API - to make it more similar to ourJavascript and Python clients. So maybe in near future I'll try to update it or will just point users to centrifuge-mobile
as main Go client - have not decided yet what to to as there is some work left anyway. So looks like we need to cooperate with this when the time comes.
I just realized that what I want to use is the server library. I taught this one was the server library. The names are a bit confusing: Gocent is called "Centrifugo HTTP API client for Go language" in the repository title. I suggest to change it with something less ambiguous like "Centrifugo server library". Sorry for the wrong report.
Your centrifugo-mobile project looks very interesting! Let us know when we can test it.
About my wrapper the goal is to get a simple api to abstract the drivers and offload the complexity to a dedicated lib, so that I can focus on my application logics. I will do it with Gocent then.
Edit: I am open for collaboration, if I can help this great project it will be a pleasure.
The names are a bit confusing
Changed like you suggested. By convention all server libraries called *cent - Cent, Rubycent, Jscent, and all client libraries called centrifuge-* - centrifuge-js, centrifuge-python ...
I am not fully understand what you mean when saying that wrapper can abstract drivers - you still use Go when using wrapper - what's the difference then? Looks I am missing sth
Please, join our chat: https://gitter.im/centrifugal/centrifugo - it's pretty active in these days.
The idea is to get something transparent and super easy to use. I would like to be able to do something like this:
server := mywrapper.SetServer("localhost", 8000, "key")
server, err := server.Connect()
if err != nil {
fmt.Println(err)
}
payload := []int{1, 2, 3}
server, err := server.Publish("channel_name", payload)
if err != nil {
fmt.Println(err)
}
The api should also provide an easy way to listen to channels, without having to deal with any complexity, like decoding json raw messages for example:
server := mywrapper.SetServer("localhost", 8000, "key")
server, err := server.Connect()
if err != nil {
fmt.Println(err)
}
server, err = server.Suscribe("some_channel")
if err != nil {
fmt.Println(err)
return
}
go func() {
fmt.Println("Listening ...")
for msg := range(server.Channels) {
if msg.Channel == "some_channel" {
fmt.Println("PAYLOAD", msg.Payload)
}
}
}()
time.Sleep(30*time.Second)
server, err = server.Unsuscribe("testchan")
if err != nil {
fmt.Println(err)
}
server, err = server.Disconnect()
if err != nil {
fmt.Println(err)
}
What I need is a short liner easy to remember API that I can use in my go programs so that I don't have to worry about the transport layer. My guideline is to make a human friendly interface, and to reduce the boilerplate code and the cognitive load when using the Centrifugo drivers.
I plan to implement this with Gocent, now that I understood it is the server library... I'll give it a try and see if my idea works in the real world.
Now, it's clear, thanks for explanation! As soon as it will be ready - ping me so I add link to it into docs. I'll come up to sth with Go client soon
When I try to publish a message in a channel
sub.Publish
always give back apermission denied
error message. Even with your example. Tested with Centrifugo 1.7Did I miss something?
Btw I am preparing an API in order to wrap your drivers into a simple and comfortable interface, saving boilerplate code: check it out.