(1)Socket.io 引用 https://github.com/GeekCookie/PomeloClient4CCC
(2)webSocket 引用 https://www.jianshu.com/p/42ec9893389a(夜雨归人创作) https://www.jianshu.com/p/c64f7607adee( Eddy Wiki创作)
CocosCreator 集成 Pomelo
下载 ccc-pomelo-chat-client 源码(https://github.com/eddy2015/ccc-pomelo-chat-client),把源码中的 ccc-pomelo-chat-client/assets/pomelo
拷贝到你的 CocosCreator 项目 assets 目录下。
文件内需要做一下修改
- pomelo-client中第5行,将var Protocol = window.Protocol修改为: var Proctocol = require("protocol")
- protobuf.js第37行:修改为: (typeof(window) == "undefined"? module.exports:{},this);
- protocol.js最后,第350行,修改为: ('undefined' !== typeof protobuf ? protobuf : module.exports, this)
这样在你的项目中即可使用 pomelo-client 相关 API 了。