DummyNegotiateController.java 1.45 KB
Newer Older
eddie.woo's avatar
eddie.woo 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 27 28 29 30 31 32 33 34
package pwc.taxtech.atms.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import pwc.taxtech.atms.dto.ConnectionData;

@RestController
@RequestMapping("/signalr/")
public class DummyNegotiateController {

    @RequestMapping(value = "negotiate", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public void getUserPermission(@RequestParam("clientProtocol") String clientProtocol, @RequestBody(required = false) ConnectionData connecitonData, 
             HttpServletResponse response) throws IOException {
        // 关闭websocket
        response.sendError(400, "__Negotiate Aborted__");
//        ClassPathResource resource = new ClassPathResource("dummyJson/negotiate.json");
//        byte[] buffer = new byte[1024];
//        InputStream inputStream = resource.getInputStream();
//        OutputStream output = response.getOutputStream();
//        response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
//        for(int length = 0; (length = inputStream.read(buffer)) > 0;) {
//            output.write(buffer, 0, length);
//        }
    }
}