Coder Social home page Coder Social logo

pomelococoscreator's Introduction

pomelococoscreator

专为cocos creator修改的pomelo游戏框架的客户端js代码,使用的是websocket协议,服务端初始化时,通讯类型选第一个(ws)

源文件列表及地址

修改内容

将上面的文件直接扔进工程,是无法直接使用pomelo,需要做一些简单修改,修改后的文件放在 pomelo这里。将代码丢进工程, 再require("relative_path/pomelo-client")即可。

使用方法

以下内容引用自pomelo-jsclient-websocket

连接到服务器

pomelo.init(params, callback);

例子:

pomelo.init({
	host: host,
	port: port,
	user: {},
	handshakeCallback : function(){}
}, function() {
	console.log('success');
});
//@param user 发送给服务器的json串
//@param handshakeCallback 握手回调

发送request到服务器

pomelo.request(route, msg, callback);

例子:

pomelo.request(route, {
    rid: rid
}, function(data) {
	console.log(dta);   
});

发送request到服务器没有回调,即通知(notify)。

pomelo.notify(route, params);

从服务器接收消息,即推送(push)。

pomelo.on(route, callback);

例子:

pomelo.on('onChat', function(data) {
    addMessage(data.from, data.target, data.msg);
    $("#chatHistory").show();
});

断开连接

pomelo.disconnect();

pomelococoscreator's People

Contributors

isghost avatar

Watchers

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