WebSocketController.java 800 Bytes
Newer Older
凌鑫's avatar
凌鑫 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
package com.changfa.controller;

import com.changfa.config.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("/ws")
public class WebSocketController {

    @Autowired
    private WebSocketServer webSocketServer;
    @RequestMapping(value = "/push",method = RequestMethod.GET)
    @ResponseBody
    public Object push(String message,String userId) throws IOException {
        webSocketServer.sendInfo(message,userId);
        return "操作成功";

    }

}