Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lonng/starx
[DEPRECATED] Lightweight, scalable ,distributed game server framework for Golang
https://github.com/lonng/starx
deprecated deprecated-repo
Last synced: 1 day ago
JSON representation
[DEPRECATED] Lightweight, scalable ,distributed game server framework for Golang
- Host: GitHub
- URL: https://github.com/lonng/starx
- Owner: lonng
- Created: 2016-02-27T06:15:20.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-07T02:57:38.000Z (over 7 years ago)
- Last Synced: 2025-01-16T21:08:43.580Z (8 days ago)
- Topics: deprecated, deprecated-repo
- Language: Go
- Homepage:
- Size: 774 KB
- Stars: 302
- Watchers: 25
- Forks: 48
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DEPRECATED
***Do not use in a production environment***, new project ref: https://github.com/lonnng/nano/
# ~~~Starx -- golang based game server framework~~~
Inspired by [Pomelo](https://github.com/NetEase/pomelo), rewrite with golang.
## Client Library
- Javascript
+ [starx-client-websockt](https://github.com/lonnng/starx-client-websockt)- C#
+ [starx-client-dotnet](https://github.com/lonnng/starx-client-dotnet)## Chat Room Demo
implement a chat room in 100 lines with golang and websocket [starx-chat-demo](https://github.com/lonnng/starx-chat-demo)- server
```
package main
import (
"github.com/lonnng/starx"
"github.com/lonnng/starx/component"
"github.com/lonnng/starx/serialize/json"
"github.com/lonnng/starx/session"
)
type Room struct {
component.Base
channel *starx.Channel
}
type UserMessage struct {
Name string `json:"name"`
Content string `json:"content"`
}
type JoinResponse struct {
Code int `json:"code"`
Result string `json:"result"`
}
func NewRoom() *Room {
return &Room{
channel: starx.ChannelService.NewChannel("room"),
}
}
func (r *Room) Join(s *session.Session, msg []byte) error {
s.Bind(s.ID) // binding session uid
r.channel.Add(s) // add session to channel
return s.Response(JoinResponse{Result: "sucess"})
}
func (r *Room) Message(s *session.Session, msg *UserMessage) error {
return r.channel.Broadcast("onMessage", msg)
}
func main() {
starx.SetAppConfig("configs/app.json")
starx.SetServersConfig("configs/servers.json")
starx.Register(NewRoom())
starx.SetServerID("demo-server-1")
starx.SetSerializer(json.NewJsonSerializer())
starx.Run()
}```
- client
```
Chat Demo
- [{{msg.name}}]{{msg.content}}
var v = new Vue({
el: "#container",
data: {
nickname:'guest' + Date.now(),
inputMessage:'',
messages: []
},
methods: {
sendMessage: function () {
starx.notify('Room.Message', {name: this.nickname, content: this.inputMessage});
this.inputMessage = '';
}
}
});
var onMessage = function (msg) {
v.messages.push(msg)
};
var join = function (data) {
if(data.code == 0) {
v.messages.push({name:'system', content:data.result});
starx.on('onMessage', onMessage)
}
};
starx.init({host: '127.0.0.1', port: 3250}, function () {
starx.request("Room.Join", {}, join);
})
```## Demo
- Client: [starx-demo-unity](https://github.com/lonnng/starx-demo-unity)
- Server: [starx-demo-server](https://github.com/lonnng/starx-demo-server)
## Wiki
[Homepage](docs/homepage.md)
## The MIT License
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.