Giter Site home page Giter Site logo

haozxuan / gocmpp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bigwhite/gocmpp

0.0 1.0 0.0 3.87 MB

An implementation of China Mobile Peer to Peer protocol in golang for both client and server sides.

License: Apache License 2.0

Go 99.72% Makefile 0.28%

gocmpp's Introduction

Build Status Coverage Status Go Report Card GoDoc

gocmpp

An implementation of China Mobile Peer to Peer(cmpp) protocol in golang for both client and server sides.

The protocol versions below are covered:

Overview

gocmpp is a library that implements China Mobile Peer to Peer(cmpp) protocol. You can use the lib to implement any app, tool or system that use cmpp protocol for both client and server side.

gocmpp is portable well. It can be used on linux, darwin or even windows.

gocmpp has covered cmpp2.x and cmpp3.x versions. It has supported the connect, submit, deliver, fwd, active test, and terminate packets of cmpp protocol. But other less use packets like cmpp query, cancel and route have not been supported. And they are not in the roadmap at all.

QuickStart

1. Download gocmpp

$go get github.com/bigwhite/gocmpp

2. Build gocmpp

gocmpp's build use the vendor mechanism introduced in go 1.5, so we need go 1.5 or later version to build it.

$export GO15VENDOREXPERIMENT="1"
$cd $GOPATH/src/github.com/bigwhite/gocmpp
$make
$make
go build -o examples/server/server examples/server/server.go
go build -o examples/client/client examples/client/client.go
go build
go build ./utils
go test
PASS
ok  	github.com/bigwhite/gocmpp	0.009s
go test ./utils
ok  	github.com/bigwhite/gocmpp/utils	0.008s

3. Run the examples

run the two programs below in order:

  • ./examples/server/server
  • ./examples/client/client

you would get the output like below:

server:

cmppserver: 2015/11/19 16:28:50 accept a connection from 127.0.0.1:49847
cmppserver: 2015/11/19 16:28:50 receive a cmpp30 connect request from 127.0.0.1:49847[0]
cmppserver: 2015/11/19 16:28:50 handleLogin: 900001 login ok
cmppserver: 2015/11/19 16:28:55 receive a cmpp active response from 127.0.0.1:49847[0]
cmppserver: 2015/11/19 16:29:00 receive a cmpp active response from 127.0.0.1:49847[1]
cmppserver: 2015/11/19 16:29:00 receive a cmpp30 submit request from 127.0.0.1:49847[1]
cmppserver: 2015/11/19 16:29:00 handleSubmit: handle submit from 900001 ok! msgid[12878564852733378560], srcId[900001], destTerminalId[13500002696]
cmppserver: 2015/11/19 16:29:05 receive a cmpp active response from 127.0.0.1:49847[2]
cmppserver: 2015/11/19 16:29:05 receive a cmpp30 submit request from 127.0.0.1:49847[2]
cmppserver: 2015/11/19 16:29:05 handleSubmit: handle submit from 900001 ok! msgid[12878564852733378560], srcId[900001], destTerminalId[13500002696]
cmppserver: 2015/11/19 16:29:10 receive a cmpp active response from 127.0.0.1:49847[3]
cmppserver: 2015/11/19 16:29:10 receive a cmpp30 submit request from 127.0.0.1:49847[3]
cmppserver: 2015/11/19 16:29:10 handleSubmit: handle submit from 900001 ok! msgid[12878564852733378560], srcId[900001], destTerminalId[13500002696]
cmppserver: 2015/11/19 16:29:13 close connection with 127.0.0.1:49847!

client:

2015/11/19 16:28:50 client connect and auth ok
2015/11/19 16:28:55 receive a cmpp active request: &{0}
2015/11/19 16:29:00 receive a cmpp active request: &{1}
2015/11/19 16:29:00 send a cmpp3 submit request
2015/11/19 16:29:00 receive a cmpp3 submit response: &{12878564852733378560 0 1}
2015/11/19 16:29:05 receive a cmpp active request: &{2}
2015/11/19 16:29:05 send a cmpp3 submit request
2015/11/19 16:29:05 receive a cmpp3 submit response: &{12878564852733378560 0 2}
2015/11/19 16:29:10 receive a cmpp active request: &{3}
2015/11/19 16:29:10 send a cmpp3 submit request
2015/11/19 16:29:10 receive a cmpp3 submit response: &{12878564852733378560 0 3}

4.How to use the library

The best start entry is the code in folder 'examples'.

  • client.go tells you how to use gocmpp in client side.
  • server.go presents you how to construct a cmpp server in gocmpp.

Who use gocmpp

gocmpp's People

Contributors

bigwhite avatar codelingobot avatar

Watchers

James Cloos 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.