Code Monkey home page Code Monkey logo

bubbles's Introduction

NoticePushService

protocol

websocket-request

{
  "s":["player.login", "uuid", "token=md5(uuid+tokenKey)"], //请求体
  "i":1 //请求序列编号
}

http-request

post http://localhost:8080/?token=md5(postData+tokenKey)
post data 
{
  "s":["notice.push", "uuid", "push-notice-data"], //请求体
  "i":1 //请求序列编号
}

{
  "s":["notice.pushAll", "push-notice-data"], //请求体
  "i":1 //请求序列编号
}

response

{
  "n":true or false, //is notice response
  "c":0, //response code 0 is success
  "m":msg,//error message
  "d":data, //response data
  "i":i  //对应请求序列编号 notice时为第n次推送
}

server-usage

mvn assembly:assembly -Dmaven.test.skip=true
cd target
tar zxvf NoticePush-0.0.1-SNAPSHOT-bin.tar.gz
cd NoticePush-0.0.1-SNAPSHOT/bin
./startup.sh

client-usage

var websocket = new WebSocket('ws://localhost:8080/websocket');
websocket.onopen = function (evt) {
    console.log("Connected to WebSocket server.");
    var data = JSON.stringify({
        s : ["player.login", "123-456", "cea19f25fcc226ea4acc27b5a8aeb592"],
        i : 1
    });
    websocket.send(data);
};

websocket.onclose = function (evt) {
    console.log("Disconnected");
    websocket = null;
};

websocket.onmessage = function (evt) {
    console.log('Retrieved data from server: ' + evt.data);
};

websocket.onerror = function (evt, e) {
    console.log('Error occured: ' + evt.data);
};

more usage

  • @TODO

bubbles's People

Contributors

ixqbar avatar

Watchers

 avatar  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.