Terry-Mao / gopush-cluster

Golang push server cluster
GNU General Public License v3.0
2.08k stars 561 forks source link

no title #2

Closed ghost closed 10 years ago

ghost commented 10 years ago

Just wondering how can I connect to the push-cluster using web socket or tcp since I can not find any sample code here.

Say, I am looking to implement a chatroom that users can pub/sub messages via web socket or tcp. How can I do this with the help of gopush-cluster? If I implement it on my own, the code should be like this:

netConn, err := net.Dial("tcp", "127.0.0.1:9999")
ws, _, err := websocket.NewClient(netConn, URL, nil, readBuffer, writeBuffer)
# read message
err = ws.ReadJSON(&v)
# write message
err = ws.WriteJSON(&v)

I mean, what should I do in the client side to connect to the gopush-cluster and receive, send messages?

Terry-Mao commented 10 years ago

there is no websocket exmaple, but i' ll add as soon as possible,

Terry-Mao commented 10 years ago

the tcp example: you can see https://github.com/Terry-Mao/gopush-cluster-sdk

Terry-Mao commented 10 years ago

or ios example: https://github.com/roy5931/GoPushforIOS

Terry-Mao commented 10 years ago

gopush-cluster not support send message, if you want to implement a char room, you can write a http api for sending message then use gopush-cluster receive message. the sdk is a full example include get comet node/get offline message and comet protocol. btw, the wiki dir has many doc, you can have a look, we'll translate to English as soon as possible.

ghost commented 10 years ago

Thank you for reply! I've read the docs twice lol. But still, I am confused.

What I am going to do is like this (not chatroom):

  1. Set up websocket connection between USERS and GOPUSH-CLUSTER
  2. If there is any new data from SERVER needed be pushed to all USERS, then SERVER http-POST to GOPUSH-CLUSTER and it will automatically push the data to all USERS via websocket.

Well it's pretty easy to implement a push server in one single machine. What gopush-cluster attracts me is the cluster :+1: That will make my service more scalable. By the way, our target clients may mostly use browser on PC but not mobile devices.

So I am not sure if gopush-cluster is suitable for it or not, still confusing :(

Terry-Mao commented 10 years ago

@pureveg

  1. i'll show you this: 1-en
  2. you can https://github.com/Terry-Mao/gopush-cluster/blob/master/wiki/web/internal_proto_zh.textile#%E6%8E%A8%E9%80%81%E7%A7%81%E6%9C%89%E6%B6%88%E6%81%AF
Terry-Mao commented 10 years ago

@pureveg i am so sorry the wiki is Chinese...

  1. gopush-cluster has a admin api for push message (HTTP-POST)

translating Englins..... if done, i'll leave you a message...

ghost commented 10 years ago

Never mind I can also read some Chinese :+1: And I also read it before I open an issue.

Originally I want to use the service provided by http://pubnub.com/ but it's kind of expensive lol. Would you mind having a look into this service? I am not sure if I can implement such service by simply using gopush-cluster or not.

ghost commented 10 years ago

And thank you for the image you uploaded. It's pretty clear to me :+1:

Terry-Mao commented 10 years ago

http://pubnub.com/ is similar to gopush-cluster

Terry-Mao commented 10 years ago

i'll write a blog about gopush-cluster performance data. in our test env(12GB, 12core) 25w messages per second(public message), 10w messages per second(private message)...

ghost commented 10 years ago

Yep this is why I am interested in gopush-cluster :-) Hope websocket can be implemented soon. Websocket may also improve the performance I think (at least in my service).

Is it also easy to scale, load balancing? Like, if one machine can not serve 500k per sec then we can simply add several machine and put it in the conf file and it's done. Right?

What's the url of your blog? I'll keep an eye on your post :)

Terry-Mao commented 10 years ago

@pureveg http://7255fc6c.ngrok.com/gopush-cluster/

Terry-Mao commented 10 years ago

fix it!!!!!

ghost commented 10 years ago

http://7255fc6c.ngrok.com/gopush-cluster/ seems incorrect. What did you fix?

Terry-Mao commented 10 years ago

javascript sdk : https://github.com/Lanfei/gopush-cluster-javascript-sdk

ghost commented 10 years ago

Oh it seems web socket is supported. This is exactly what I want. Thank you!