Git Product home page Git Product logo

gosocket's Introduction

goSocket

A socket server which achieve following function by native Go http package:

  1. A custom communication protocol between server and client;

  2. A custom connecting mechanism of heartbeating;

  3. Read operational parameters from config files;

  4. A router-controller structure to decouple codes of server.

You can see all the details in my chinese blog

goSocket

一个通过Go语言原生包实现了如下功能的socket server:

  1. 自定义通讯协议

  2. 通过心跳机制维护连接

  3. 从配置文件中读取系统参数

  4. 通过 router-controller 机制解耦服务器

详情可参加我的中文blog

##Example:

//modify a controller in /utils/router.go
type EchoController struct  {

}

func (this *EchoController) Excute(message Msg)[]byte {
	mirrormsg,err :=json.Marshal(message)
	Log("echo the message:", string(mirrormsg))
	CheckError(err)
	return mirrormsg
}


func init() {
	var echo EchoController
	routers = make([][2]interface{} ,0 , 20)
	Route(func(entry Msg)bool{
		if entry.Meta["meta"]=="test"{
			return true}
		return  false
	},&echo)
}

//after setting parameters in config.yaml, run server.go
func main() {
	startServer("./conf/config.yaml")
}

gosocket's People

Contributors

gislu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.