GithubHelp home page GithubHelp logo

pomelo-cocos2d-js's Introduction

#pomelo-cocos2d-js

pomelo-cocos2d-js is a library for using in pomelo with cocos2dx-js

#Usage using browserify to resolve library dependencies

add this library to your project

npm install pomelo-cocos2d-js --save

add to your browserify main.js

require('pomelo-cocos2d-js');

in cocos2d-js you can also add dist/pomelo-cocos2d-js.js file into jsList

then you can use pomelo object under the gloal window object the same as using in the browser

simple chat test

var pomelo = window.pomelo;

var route = 'gate.gateHandler.queryEntry';
var uid = "uid";
var rid = "rid";
var username = "username";

pomelo.init({
	host: "127.0.0.1",
	port: 3014,
	log: true
}, function() {
	pomelo.request(route, {
		uid: uid
	}, function(data) {
		pomelo.disconnect();
		pomelo.init({
			host: data.host,
			port: data.port,
			log: true
		}, function() {
			var route = "connector.entryHandler.enter";
			pomelo.request(route, {
				username: username,
				rid: rid
			}, function(data) {
				cc.log(JSON.stringify(data));
				chatSend();
			});
		});
	});
});

function chatSend() {
	var route = "chat.chatHandler.send";
	var target = "*";
	var msg = "msg"
	pomelo.request(route, {
		rid: rid,
		content: msg,
		from: username,
		target: target
	}, function(data) {
		cc.log(JSON.stringify(data));
	});
}

License

(The MIT License)

Copyright (c) 2012-2015 NetEase, Inc. and other contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

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.

pomelo-cocos2d-js's People

Contributors

fantasyni avatar yourihua avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pomelo-cocos2d-js's Issues

使用jsb连接不上pomelo?

问个问题啊
我使用的 cocos2d-js-v3.6
在project.json的jsList中添加pomelo-cocos2d-js.min.js文件路径

在连接pomelo服务器时 有这样的错误:
D/cocos2d-x debug info( 3050): JS: connect to ws://192.168.1.103:3010
D/cocos2d-x debug info( 3050): [WebSocket::init] _host: 192.168.1.103, _port: 30
10, _path: /
D/cocos2d-x debug info( 3050): JS: io error!
D/cocos2d-x debug info( 3050): JS: ERROR : socket error: { type: 'error' }
D/cocos2d-x debug info( 3050): JS: connection close!
D/cocos2d-x debug info( 3050): filename == messageHint_1.json
D/cocos2d-x debug info( 3050): JS: ERROR : socket close: { type: 'close' }

怎么解决啊?

Is this code possible to use cocos2d-js 3.14 version?

I am making a p2p baseball with my team.

and looking for some server I can use with cocos2d-js.

And finally i found pomelo!!! but im worry about the version..

is it possible to use pomelo without any problem in cocos2d-js v 14??

这个项目还会维护更新吗?

我在使用过程中断开pomelo连接。
会报一个socket.io close
socket close: CloseEvent {reason: "", code: 1000, wasClean: true, clipboardData: undefined, path: NodeList[0]…}
不影响功能的使用! 看着有点异怪!
最主要咨询下 还会维护更新吗?

pomelo.removeEventListener

update this version , pomelo.removeEventListener function not exits, why ?
i use this project long time!

Why wss isn't supported?

I'm making a facebook game and wss is required if I want to publish the game to facebook game center, would you please add option to support wss? Thanks in advance.

这次修改成browerify模式,要怎么来使用

我目前是在jsfile中直接引用 "src/pomelo/dist/pomelo-cocos2d-js.min.js",
这个方式是jsb和web都能通用吗?
另外,我原来使用pomeolo经常用到了pomelo.removeEventListener,这个本属于EventEmiter的方法,怎么不能使用了呢

不知道能不能支持多个连接

由于实时性的需要,需要和服务端建立两个连接,我看了下代码发现他好像不支持多个连接,不知作者是否愿意让他支持多个连接!!!!!

在android的微信和qq浏览器访问,服务器报could not find handle invalid data package

我用最新的(0.1.4)pomelo-cocos2d-js 在android的微信和qq浏览器会连不上服务器,服务器报could not find handle invalid data package,其他浏览器和cocos运行正常,大概是因为pomelo-cocos2d-js的pomelo版本过低导致socket的数据包类型或格式不对,我服务器用的是pomelo1.1.9,我把模板的build.js放到客户端,这时候微信和qq浏览器访问就正常了,但我不知道怎么整合代码,也报pomelo-cocos2d-js中index.js第一句:
var Util = require('util');就报错:Error: can't open : No such file or directory 纠结啊

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.