mirror of
https://github.com/wyb10a10/cocos_creator_framework.git
synced 2026-05-13 17:28:55 +08:00
示例显示服务器返回内容
This commit is contained in:
@@ -9,21 +9,26 @@ const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export default class NewClass extends cc.Component {
|
||||
@property
|
||||
text: string = 'hello';
|
||||
@property(cc.Label)
|
||||
textLabel: cc.Label = null;
|
||||
@property(cc.Label)
|
||||
urlLabel: cc.Label = null;
|
||||
@property(cc.RichText)
|
||||
msgLabel: cc.RichText = null;
|
||||
private lineCount: number = 0;
|
||||
|
||||
onLoad() {
|
||||
let Node = new NetNode();
|
||||
Node.init(new WebSock(), new DefStringProtocol());
|
||||
Node.setResponeHandler(0, (cmd: number, data: NetData) => {
|
||||
console.log(`${data}`);
|
||||
Node.setResponeHandler(0, (cmd: number, data: NetData) => {
|
||||
if (this.lineCount > 5) {
|
||||
let idx = this.msgLabel.string.search("\n");
|
||||
this.msgLabel.string = this.msgLabel.string.substr(idx + 1);
|
||||
}
|
||||
this.msgLabel.string += `${data}\n`;
|
||||
++this.lineCount;
|
||||
});
|
||||
NetManager.getInstance().setNetNode(Node);
|
||||
|
||||
}
|
||||
|
||||
onConnectClick() {
|
||||
|
||||
Reference in New Issue
Block a user