cc.Class({
extends: cc.Component,
properties: {
//外部传入account输入款
account:cc.EditBox,
//外部传入password输入款
password:cc.EditBox,
tips:cc.Node,
labyer:cc.Label,
},
onLoad () {},
start () {
this.ws=null;
this.conect();
},
conect:function()
{
this.ws = new WebSocket("ws://192.168.0.118:8000/login");
//写好的服务端,根据不同的返回值,输出对应的提示
this.ws.onopen = function (event) {
console.log("Send Text WS was opened.");
}.bind(this);
this.ws.onmessage = function (event) {
switch(JSON.parse(event.data).cmd)
{
case 2:
this.tips.active=true;
this.labyer.string='注册失败';
break;
case 3:
cocos-creator连接服务端 注册与登入
最新推荐文章于 2023-11-05 21:04:07 发布
