1234567891011121314151617181920212223242526272829303132 |
- 'use strict';
- const Controller = require('egg').Controller;
- class ChatController extends Controller {
- async index() {
- this.ctx.socket.emit('res', 'test11111111111');
- }
- async message() { // 方法通过 客户端 this.emit('message',{})//触发
- // this.ctx.socket.emit('message', 'test222222222222');
- const params = this.ctx.args[0];
- // this.ctx.service.message.sendPeerMessage(params);
- const params_ = JSON.parse(params);
- const newdata = { roomid: params_.client, userid: params_.token, isonline: '1' };
- const url = 'http://127.0.0.1:5555/api/onlive/lookuser/updateonline';
- await this.ctx.curl(url, {
- method: 'post',
- headers: {
- 'content-type': 'application/json',
- },
- dataType: 'json',
- data: newdata,
- });
- console.log(2, params);
- }
- async online() { // modelMessage.sendOfflineMessage(socket, data.userId);
- }
- }
- module.exports = ChatController;
|